Error messages generated by ValueFormatter are not really useful

Kirby

Well-known member
Affected version
2.3.0
If an entity field has min/max/maxLength/allowedValues/match constraints and those are not satisfied when trying to save the entity, generic error messages like

Please enter a value that matches the requirements for this field.
are generated.

Those messages might ultimately be displayed to the user - this is not really that helpful, especially if the user just submitted a form with multiple fields.

Of course it is already possible to show better error messages to the user, but this requires custom verifyXXX methods which kinda defeats the simplicity of min/max/maxLength/allowedValues/match

To improve this, it would be very useful if columOptions could have additional filelds like minErrorPhrase, maxErrorPhrase, maxLengthErrorPhrase, allowedValuesErrorPhrase and matchErrorPhrase that would be used instead of the hardcoded phrases if available.

This would allow developers to easily define custom, precise error messages without implemeting a verify method ever ytime.

Ideally XenForo could probably even ship additional phrases that include the field name, like please_enter_value_that_matches_requirements_for_field_x so developers can just use that in case a fully customized phrase is not necessary / desired.
 
Last edited:
XenForo will automatically display a phrase with the same name as the column in other cases, this would make an excellent case for the same functionality for automatically phrasing column names for which field was the error.
 
Back
Top Bottom