Symfony 4:从应用于集合类型的计数约束中获取错误消息

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

我正在使用 symfony 4 的集合类型,我希望对该集合应用计数约束。

我已经学习了这个教程:https://symfony.com/doc/current/form/form_collections.html

我的想法是直接在集合上应用约束:

$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])
        ]
    ])
;

但这不起作用:我没有收到任何错误消息...

我也曾尝试直接在实体 Task 中使用此约束,但没有成功。

那么如何从应用于集合类型的计数约束中获取错误消息?

正如@emix 在评论中所说

With NotNull you tell the validator the field cannot be empty. Using the Count validator you limit the collection’s size (using the min/max or both)

为了打印错误,我将参数 error_bubbling 设置为 CollectionTypefalse