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.
The documentation explains how to let know clientside_validation of custom #element_validate validations.
We currently have custom validations for various form elements using $form['#validate'][] = 'our_validation_function';
, on a per form basis.
Can those #validate functions be recognized by clientside_validation?
Is there any advantage on using #element_validate?
Thanks !
Comments
Comment #1
attiks CreditAttribution: attiks commented#element_validate works on an element, #validate on the form
We'll have a look
Comment #2
Jelle_SFixed in latest dev & updated the documentation.
EDIT:
In answer to your question:
#element_validate
validates a single element in your form, so you're more likely to be able to reuse the function for other elements (e.g. checking for positive numeric values etc.)#validate
acts on the entire form, so you have more context.There's no 'best practice' defined about their usage as far as I'm aware.
Comment #3
rafamd CreditAttribution: rafamd commentedattiks++
Jelle_S++
Thanks so much for making this module plain awesome! Everything's very clear.