Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

User Forms: Conditional Redirection on Form Submission


Go to End


3 Posts   2085 Views

Avatar
gakenny

Community Member, 153 Posts

31 July 2010 at 3:03pm

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

Avatar
Willr

Forum Moderator, 5523 Posts

31 July 2010 at 6:08pm

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.

Avatar
gakenny

Community Member, 153 Posts

1 August 2010 at 8:27am

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