Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi. First of all, thank you for the nice module, Field validation + Clientside Validation combination saved a lot of my time...
I faced a problem when tried to add Field validation rule to one of Address Field's columns: javascript validation (the same rule) was applied to all widget's textfields, not just to one i'd targeted. Looks problem can appear for other widgets which contain several form elements, not for address field only: so i've tested on Double field and experienced the same problem...
Comments
Comment #1
antongp CreditAttribution: antongp commentedHere is fix in the clientside_validation_field_validation_regular() which solved the problem for me.
So clientside_validation_field_validation_regular() ignores rules for elements named format or summary if column name is value. This checking was replaced by exact column name comparison, also $element['#parents'] is used for checking instead of $element['#name'].
I'm not sure if this is 100% right way to fix the problem, so it needs for review.
Thank you
Comment #2
attiks CreditAttribution: attiks commentedComment #4
Jelle_SFixed in latest dev. Thanks for the patch!
Comment #6
antongp CreditAttribution: antongp commentedAwesome! Thanks!
Comment #8
nbouhid CreditAttribution: nbouhid commentedGuys, FYI - AFAIK, this is breaking validations for checkboxes/radio buttons. I'll update after debugging and seeing how can we fix it.
Comment #9
nbouhid CreditAttribution: nbouhid commentedI found this issue when working on Clienside validation + field validation does not support overriding default required message, when validations applied to radio buttons weren't working.
After checking it, and trying to find the best way to fix this issue, I'm just skipping this validation for radio/checkbox/selects.
The explanation is the following: default text fields, textareas, addresfield elements, etc. saves the column name as the last item on the #parents array. But selects/radios/checkboxes doesn't, so it won't pass this column validation. I tried to understand why is this happening on the core, but I'm not sure. If someone could explain why this happens, we may find a better solution.
So far, this works, I tested it with many elements (including addressfield) and seems to work fine.
It also fixes a few tests on select boxes using testswarm.
Comment #10
nbouhid CreditAttribution: nbouhid commentedSetting the proper issue status.
Comment #11
antongp CreditAttribution: antongp commentedHi.
I don't think it's specificity of form element types like checkbox/checboxes, radio/radios, etc. This is actually how core's options module (submodule of the field) works, i.e. it handles form elements without col name, but then transforms submitted data to proper structure for saving to storage. See last lines of the options_field_widget_form() and also _options_form_to_storage().
Thinking how to properly handle this case... At least options stores col name in element's #value_key, but i think some additional checking is needed.
P.S. I think you should create separate issue and list this issue as related.
Thanks.