I have the following form class:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('existingfolder', 'entity', array(
'class' => 'ImageBundle:Folder',
'required' => false,
))
->add('folder', 'text', array('required' => false))
->add('file', 'file');
}
How can I set up the validation so that either the existingfolder or folder field must be filled (but not both of them)?
Any advice appreciated.
Thanks.
Use the True or Callback validation assert, here an example to check if the user must give at least one of the folders:
Here another example if the user must give ONLY one field but not both:
EDIT:
Callback validation inside a form (I found an example here):