public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('description', null, array('required' => false));
$builder->add('photographer', null, array('required' => false));
$builder->add('photographer_url', null, array('required' => false));
$builder->add('place', null, array('required' => false));
$builder->add('image', 'file', array('constraints' => array(new Assert\File(), new Assert\NotNull())));
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($options) {
$image = $options['image'];
$form = $event->getForm();
$form->remove('image');
if ($image && null !== $image->getId()) {
$form->add('image', 'file', array('required' => false));
} else {
$form->add('image', 'file', array('constraints' => array(new Assert\File(), new Assert\NotNull())));
}
});
}