tags:

views:

166

answers:

1

I have an admin form that lets users create entities that require an image. So in the form class, I have a sfValidatorFile object that sets the 'required' option to true. This is perfect behavior when the user creates a new entity. The problem arises when they edit an existing entity. They shouldn't have to select an image every time they edit the entity, but if they don't, symfony returns an error complaining that the image is required. So is it possible to make sfValidatorFile use the 'required' option conditionally?

+4  A: 

new sfValidatorFile(array(....., 'required' => $this->isNew()));

Coronatus
Beautiful! works like a charm, thanks
Arms