sonata-project/SonataAdminBundle — pull request #693 by SebastienRaymond (2012-04-18 13:50:29+00:00)
Title: 2.0

Hi,

I wanted to display an error message from the preRemove method of my Admin subclass and display this message as a flash error message and I figured out this could not be done hence my little tweaking around the code.

This is the reason behind my pull request :

public function preRemove($object)
{
if ($object->isMainNode())
{
$error = 'A main node cannot be deleted.';
$ErrorMessage = $this->getTranslator()->trans($error, array(), $this->getTranslationDomain());

throw new \Exception($ErrorMessage);
}
}

Thanks a lot for reading,