Validation error messages use the field name instead of the field label #6685
Replies: 6 comments
-
All fields will be getting a make-over as part of 2.8 (we have an issue for every field on the 2.8 milestone, eg #4662). That's a perfect time to address this. |
Beta Was this translation helpful? Give feedback.
-
@pdclark Can you check and see if we are using field labels where they should be used now for required field error messages? @bemdesign-er for custom error messages on submit, you can try this:
|
Beta Was this translation helpful? Give feedback.
-
e.g., <?php
add_filter( 'pods_field_validate_text', static function( $validate, $value, $name, $options, $fields, $pod, $id, $params ) {
if ( false === $validate || is_array( $validate ) ) {
return $validate;
}
if ( 'required_plain_text' === $name && '123456' === $value ) {
$errors = [];
$errors[] = 'You cannot enter "123456" for this field.';
return $errors;
}
}, 10, 8 ); Which kind of worked — but the error only went to PHP error log, not to UI. |
Beta Was this translation helpful? Give feedback.
-
@pdclark @sc0ttkclark However, I also found a filter in PodsForm: https://github.com/pods-framework/pods/blob/main/classes/PodsForm.php#L1180 @sc0ttkclark We'll need to address this as there are more filters in PodsForm that might relate to Field filters.. EDIT: Added a separate issue to address this. |
Beta Was this translation helpful? Give feedback.
-
As for the error log in the UI. Related: #5464 (@sc0ttkclark why is this punted? IMO this is a blocking issue) |
Beta Was this translation helpful? Give feedback.
-
@JoryHogeveen Both of these issues seem to have existed before Pods 2.8. There's more work to be done on the React side of things for all forms to make a REST API validation call before save to be able to prevent the save itself from occurring on any form if it fails initial server validation. Once that is done, we can look at addressing this and #5464 more fully. |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
I would like the ability to change or modify field validation messages on a per-field basis. This is particularly useful on select fields where normally the validation message uses the not-always-user-friendly programatic name for the field.
Describe the solution you'd like
When setting up a field for a Pods item, have an additional area to capture pod-editor specified error validation message for that field.
Describe alternatives you've considered
Custom Javascript after the validation error message is generated to change the message - cons with this approach is that it's not as user friendly to do (requires javascript programming) and can be problematic with timing (identifying when the error validation message is shown and when to fire off the error message customization script).
Additional context
The use of progromatic field names for validation error messages may be a limitation of the js validation library being used.
Beta Was this translation helpful? Give feedback.
All reactions