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.

Customising the CMS /

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

Redirect after create


Go to End


1265 Views

Avatar
Eugene

Community Member, 2 Posts

13 April 2013 at 1:21am

When you create a new DataObject item in the CMS the default behaviour is that you're redirected to the item you just created.

I would like to be redirected to a different CMS url, so I placed some redirect code inside onAfterWrite in my DataObject extension class:

public function onAfterWrite() {
parent::onAfterWrite();
Controller::curr()->response->addHeader("X-ControllerURL", "admin/customurl");
Controller::curr()->redirect('admin/customurl');
}

However this doesn't redirect me back to /admin/customurl.

I have also tried not calling parent::onAfterWrite(); but still no joy.

Could someone point me in the right direction please?