I am using a collection type of symfony 4, and i wish to apply a count constraint to this collection.
I have followed this tutorial : https://symfony.com/doc/current/form/form_collections.html
My idea is to apply the constraint directly on the collection :
$builder
->add('tags', CollectionType::class, [
'entry_type' => Tag::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'by_reference' => false,
'constraints' => [
new Assert\Count(['min' => 1, 'max' => 3])
]
])
;
But this does not work : I do not get any error message...
I have also try to use this constraint directly in the entity Task
, without success.
So how can I get the error message from count constraint applied on collection type ?