- Issue created by @gapple
The Content Security Policy module has a lengthy form with two vertical tabs that have identical components, and each component has similar fields. To help users locate which item failed validation, the message included the vertical tab and component for the error.
In converting to use config validation and #config_target for the form, the error message is now only the one provided by the violated constraint.
Overriding the form's formatMultipleViolationsMessage() allows parsing the $form_element_name to provide additional context, but it is only called when an element receives multiple violations. Single violations can't be changed to provide additional context, and the message format differs between single and multiple violations.
- Add a formatViolations property to ConfigTarget that accepts an optional callable.
- Add a formatViolationsMessage() method to ConfigTarget that is called instead of ConfigFormBase::formatMultipleViolationsMessage() if present.
- Always call formatViolationsMessage() for any number of violations.
Active
11.0 🔥
forms system