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:

Customising the CMS /

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

Redirect after create


Go to End


889 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?