In my Doctrine entity, which is data_class
for my form I have a file property defined like this:
/**
* Image.
*
* @AssertNotBlank
* @AssertFile
* @AssertImage(minWidth="138", minHeight="96")
*/
protected $file;
Also, added it to form type with ->add('file', 'file')
...
Creating entity works perfect, but the problem is when I use form to update this entity. It asks for file again, since it has @AssertNotBlank. Since I have other fields in this form, I don't want to reupload image on every update.
When I remove @AssertNotBlank, everithing works fine, but I want this file field to be mandatory.
Any idea?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…