mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
adding constraint to fields
This commit is contained in:
parent
e5c7a4a342
commit
0e848e0829
@ -13,6 +13,8 @@ use Chill\MainBundle\Export\FormatterInterface;
|
|||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
use Symfony\Component\Validator\Constraints\Callback;
|
||||||
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render a list of peoples
|
* Render a list of peoples
|
||||||
@ -59,7 +61,16 @@ class ListPerson implements ListInterface
|
|||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => array_combine($this->fields, $this->fields),
|
'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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
))]
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,3 +12,6 @@
|
|||||||
'Closing date can not be null': 'La date de fermeture ne peut être nulle'
|
'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 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%
|
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
|
Loading…
x
Reference in New Issue
Block a user