ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Safecracker alternate return page

April 25, 2012 3:14pm

Subscribe [4]
  • #1 / Apr 25, 2012 3:14pm

    jensa

    109 posts

    Hi,
    I’m using Safecracker on a site and it has made it really swift to build a fairly complex workflow. Brilliant plugin!

    However - the client want’s to have TWO submit methods in the form - one that saves and takes the user back to an overview + one that saves and take the user further into the workflow. Is there any way to accomplish such a thing?

    J

  • #2 / Apr 26, 2012 12:53pm

    Shane Eckert

    7174 posts

    Hello Jensa,

    Thank you for posting your question here on the ExpressionEngine forums.

    I am not aware of a way of doing this. I checked out a few of the form add-ons at Devot:ee. Nothing there seems to do this either.

    If you would like, I can move this to the Development and Programming forum. There might be an idea about this over in that forum.

    Please let me know.

    Cheers,

  • #3 / Apr 26, 2012 4:16pm

    jensa

    109 posts

    Yeah. Please do. I’ll probably hack a solution in, but I’d love to get some opinions from ppl that know the module.

    J

  • #4 / Jul 08, 2012 3:46pm

    jeffpullinger

    15 posts

    Hello Jensa,

    Did you work out a way to get two different submit buttons working and going to two different urls?

    Would love to see your solution if possible, I’m needing to do something very similar,

    thanks,

    Jeff

  • #5 / Jul 08, 2012 6:22pm

    jensa

    109 posts

    Hi Jeff,
    I had a couple redirect issues with this site. For one (redirecting users based on their Group ID) I made quick extension: http://devot-ee.com/add-ons/jc-redirect

    For the other one, I added an extra form field that had a “no” value. On the alternat Submit-button I had this tiny [removed]

    $(".moveon1").click(
      function() {
       $('#alternate1').attr("value", "yes");
       $('#publishForm').submit();
      }
     );

    If that submit-button was clicked, the stored value would be set to “yes”. If the other submit-button was pressed, it would remain “no”. The return URL was a template that then looked up the value that were set and then did this little trick using the Stash-extension and my own redirect script above:

    {exp:channel:entries channel="somechannel" author_id="CURRENT_USER" dynamic="off" limit="1"}
    
    {exp:stash:set_list name="redirect" parse_tags="yes" parse_conditionals="yes" parse_depth="2"}
     {stash:murl}
      {if alternate1 == "no"}http://mysite.eu/sub/{if:else}http://mysite.eu/sub/otherurl/{ordernumber}/{/if}
     {/stash:murl}
    {/exp:stash:set_list}
    
    {exp:stash:get_list name="redirect"}
     {exp:jc_redirect location='{murl}' mode="plain"}
    {/exp:stash:get_list}
    
    {/exp:channel:entries}

    A little “clumsy” but it works well.

    J

  • #6 / Jul 11, 2012 4:58am

    jeffpullinger

    15 posts

    HI Jensa,

    thanks for this,

    hadn’t thought of a redirect after the submit, that’s a great idea.

    *starts recoding*

    thank you.

    Jeff

  • #7 / Jul 25, 2012 4:41pm

    Michael Rog

    179 posts

    This is a really clever solution, actually. Thanks, jensa! I’ve been looking desperately for a way to do this.

    Now that Stash can grab post variables, perhaps it makes sense to get the desired values that way…

    Also, I believe you can set name=’‘ and value=’‘ parameters on the Submit button — If you did that, you wouldn’t need to use an extra hidden field or rely on JavaScript…

    *runs off to test theory*

  • #8 / Jul 26, 2012 11:23am

    Michael Rog

    179 posts

    Well… my theory about passing form values directly didn’t work — The $_POST array is cleared by the time we get to the redirect page. So, jensa’s solution of storing the values in custom fields and pulling it out of exp:channel:entries is the way to go.

    However, you CAN use the name parameter of the submit button to store its value into a custom field, in order to not be dependent on JavaScript for conditional behavior.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases