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] Doesn´t work Director::redirect() is SS3?


Reply

3 Posts   336 Views

Avatar
Bereusei

25 October 2013 at 2:54am Community Member, 94 Posts

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

25 October 2013 at 3:37am Community Member, 146 Posts

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

25 October 2013 at 4:31am Community Member, 94 Posts

Ahh, great. Thanks!