Closed
Description
Description
It would be handy to add the same violation to multiple form fields, if you want to display the same error message at two fields, e.g. "You need to provide either your name or your email address"
https://symfony.com/doc/current/reference/constraints/Callback.html
Example
The (for the user) easiest way would be to just repeat atPath()
:
$context->buildViolation('...')->atPath('name')->atPath('email')->addViolation();
Instead of having to repeat the entire violation (current status quo):
$context->buildViolation('...')->atPath('name')->addViolation();
$context->buildViolation('...')->atPath('email')->addViolation();