sonata-project/SonataAdminBundle — pull request #454 by zhil (2011-12-09 11:53:07+00:00)
Title: added ability to detect edit Form easily

Sometime its required to detect which one form is build in configureFormFields - edit form or create form.
For example, file fields in most cases are required on create form and optional in edit form.

Right now I use code like
$entity = $this->getSubject();
.....
->add('videoSourceFileUpload','file',array('required'=>(($entity->getId() != null)?false:true)))

But it looks like a hack and code kind of ugly. I propose to add dedicated method for this purpose, so code will looks like
->add('videoSourceFileUpload','file',array('required'=>! $this->isEditForm())

Let me know what do you think about this patch.