http://www.symfony-project.org/snippets/snippet/9
Sometimes, you want to do something just before or just after saving or deleting an object in the admin generator. To do that, you can override the saveObject() and/or deleteObject() method in your actions.class.php file:
protected function saveCustomer($customer) { // pre save hook $customer->setManagerId($this->getUser()->getManagerId()); // call the parent save() method parent::saveCustomer($customer); // post save hook }
You can also bypass the parent method if you want.
protected function deleteCustomer($customer) { $customer->isDeleted(true); // save the customer object $this->saveCustomer($customer); // bypass the deletion by not calling the parent method }
by Fabien Potencier on 2006-05-21, tagged admin
For example, say I access my 'apps/my_app/modules/my_mod' module via
http://my_host/my_proj/my_app_dev.php/my_mod/
The illustrated code should be put at:
apps/my_app/modules/my_mod/actions/actions.class.php
as
protected function saveMyMod($info) { }
If you need to access the values passed from the admin generator edit form, the
$this->getRequestParameter('my_mod');
would returns an array containing the values filled in the admin generator edit form.
documented on: 2007.08.23