I'd like to create different fields configuration for create and edit actions in Sonata Admin Bundle.
Is there any way to determine it except checking $this->getSubject()->getId()
in Sonata\AdminBundle\Admin\Admin::configureFormFields()
?
You can also do this:
protected function configureFormFields(FormMapper $formMapper) {
if ($this->isCurrentRoute('create')) {
// CREATE
}
else {
// EDIT
}
}
with:
if($this->getRequest()->get($this->getIdParameter()) == null){
// create
} else {
// edit
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With