Reputation: 378
I would like to remove the delete route for certain objects (which are linked to others...).
Is there a way to remove Routes in the configureRoutes method depending on the edited object (for example the id)?
Or is there a way to do it in the configureFormFields method ?
Upvotes: 3
Views: 1381
Reputation: 5092
EDIT: This is a very old answer, so it may or may not work in your case
To get the current object inside XXXAdmin class use:
$this->getSubject();
protected function configureFormFields(FormMapper $formMapper) {
$product = $this->getSubject();
if ($product->getId()) { // editing
//
}
//...
}
public function configureRoutes(\Sonata\AdminBundle\Route\RouteCollection $collection) {
$product = $this->getSubject();
if ($product->getId()) { // editing
$collection->remove('route');
}
}
Upvotes: 1