diff --git a/Export/Export/ListPerson.php b/Export/Export/ListPerson.php index 7a565893c..f5017f032 100644 --- a/Export/Export/ListPerson.php +++ b/Export/Export/ListPerson.php @@ -13,6 +13,8 @@ use Chill\MainBundle\Export\FormatterInterface; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Component\Validator\Constraints\Callback; +use Symfony\Component\Validator\Context\ExecutionContextInterface; /** * Render a list of peoples @@ -59,7 +61,16 @@ class ListPerson implements ListInterface 'multiple' => true, 'expanded' => true, 'choices' => array_combine($this->fields, $this->fields), - 'label' => 'Fields to include in export' + 'label' => 'Fields to include in export', + 'constraints' => [new Callback(array( + 'callback' => function($selected, ExecutionContextInterface $context) { + if (count($selected) === 0) { + $context->buildViolation('You must select at least one element') + ->atPath('fields') + ->addViolation(); + } + } + ))] )); } diff --git a/Resources/translations/validators.fr.yml b/Resources/translations/validators.fr.yml index 38fabbbbf..b6ea52607 100644 --- a/Resources/translations/validators.fr.yml +++ b/Resources/translations/validators.fr.yml @@ -12,3 +12,6 @@ 'Closing date can not be null': 'La date de fermeture ne peut être nulle' The date of closing is before the date of opening: La période de fermeture est après la période d'ouverture The birthdate must be before %date%: La date de naissance doit être avant le %date% + +#export list +You must select at least one element: Vous devez sélectionner au moins un élément \ No newline at end of file