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?