Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » User Forms: Conditional Redirection on Form Submission

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1102 Views
  • gakenny
    Avatar
    Community Member
    153 Posts

    User Forms: Conditional Redirection on Form Submission Link to this post

    Hello,

    I have a User Form defined on my web site and I would like to cause this to redirect to another page after submission in the case of a specific dropdown value.

    Is it possible to extend this module to allow this conditional redirection to occur instead of displaying the successful submission page?

    Thanks,

    Gary

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: User Forms: Conditional Redirection on Form Submission Link to this post

    What you would have to do is subclass the UserDefinedForm page type to your own class or you could hack round in the module but thats not really recommended.

    The redirection is handled in UserDefinedForm::process() (at the bottom) you would need to change that in your subclass to look up dynamically from your form (eg via a switch statement). You can access the fields in the values and fields in the that process function so you would be sweet. Making it work generically would be a bit trickier (eg for more that 1 form) but if its just for 1 form then looking up the value in the $data array wouldn't break too much.

  • gakenny
    Avatar
    Community Member
    153 Posts

    Re: User Forms: Conditional Redirection on Form Submission Link to this post

    Thanks Will!

    I was thinking that some kind of method like that would be the best approach. I'll give it a shot!

    Thanks for the support.

    Gary

    1102 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.