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.

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   1024 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!