Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

Symfony 4 : get the error message from count constraint applied on collection type

$
0
0

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 ?


Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>