Allow change to $value
malc_b - May 18, 2009 - 13:14
| Project: | Validation API |
| Version: | 6.x-1.0 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
It would be useful to allow the validation API to change the $value to correct for some user errors automatically. For example upper/lower case. If the user is meant to enter their username, password, discount code, etc. in all upper case or all lower case then the validation api could automatically fix that for the user rather than just telling them it was wrong.

#1
FYI here is my work around. Validation is set to php. As well as the validation I also have this right at the end after all the validation has passed.
$form_state['values'][$element['#field_name']][0]['value'] = strtoupper($value);return true;
That sets the saved string to be all upper case (which I what I want here). This works since $form_state is available and is passed around by reference. In this field the value I want to change is field_name[0]['value'] for different fields this could be uid, or email etc. so this only works for this type of field so you would need to clone the validator if it was used on multiple types or fix this limitation.