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   373 Views

Avatar
Bereusei

Community Member, 94 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, 171 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, 94 Posts

25 October 2013 at 4:31am

Ahh, great. Thanks!