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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

[SOLVED] Doesn´t work Director::redirect() is SS3?


Go to End


3 Posts   927 Views

Avatar
Bereusei

Community Member, 96 Posts

25 October 2013 at 2:54am

Hey guys,

I have a simple Form, which sends e-mails. If the formaction is done, the previous page must be loaded.
In SS 2.4 I have used this:

function doSubmitEntry($data, $form){
...
     $email = new Email($from,$to,$subject,$body);		
     $email->send();
			
     Director::redirect($this->Link("?success=1"));
     return;
}

The system sends the e-mails correctly. But the previous page isn´t loaded and the user stays on www.mysite.com/mypage/Form.

I couldn´t find the right syntax for SS3. Can anyone help?

Avatar
kinglozzer

Community Member, 187 Posts

25 October 2013 at 3:37am

Director::redirect() doesn't exist any more, the redirect() method was moved to the controller class. As you're already in a controller, your code can just use:

return $this->redirect($this->Link("?success=1"));

Avatar
Bereusei

Community Member, 96 Posts

25 October 2013 at 4:31am

Ahh, great. Thanks!