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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

(solved) Redirect to child page after form submit?


Reply


2 Posts   1412 Views

Avatar
prawnstar

Community Member, 127 Posts

21 March 2011 at 4:31pm

Edited: 21/03/2011 6:51pm

Once I process my form submission I'd like to redirect to a child page of the form.

I'm sure I'm just missing something simple here.

I'm trying this (and many variations of):

function doSignup($data, $form) {
   $submission = new LandingFormSubmission();
   $form->saveInto($submission);
   $submission->write();
   Director::redirect($this->Children()->First()->Link());
}

EDIT:
This isn't the first time this has happened to me. Shame on me. I forgot that this page was "Not shown in menu" so Children() was empty.
The director should have been:
Director::redirect($this->AllChildren()->First()->Link());

Note to anyone else looking at this. If your page is not shown in the menu(Behavior tab), then you have to use AllChildren(), not Children().

Chris.b

Avatar
Blackthorn87

Community Member, 27 Posts

11 November 2011 at 11:03pm

Hey there,

I know this post is quite old, but I was wandering if you could tell me where to insert the code you have mentioned in the post. I have a client who wants a solution similar to what your post talks about.

They want to create a series of forms that when you submit the first one, the information contained is submitted as normal, but then the page is redirected to the next form in the sequence, and so on til the last form. They also want to be able to adjust which is the next form in the sequence using the CMS.

Any help would be much appreciated,

Thanks,

Arun.