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.
As per documentation available for Adding custom validation rules - Webform Validation hooks it is given that,
In hook_webform_validation_validators() , custom_error and custom_data are optional parameters
- custom_error (optional): define whether a user can specify a custom error message upon creating the validation rule.
- custom_data (optional): define whether custom data can be added to the validation rule
Accordingly,
I have implemented hook_webform_validation_validators() in my custom module under
function hook_webform_validation_validators() {
return array(
'is_empty' => array(
'name' => "Is Empty",
'component_types' => array(
'number',
'textfield',
'email',
),
'custom_error' => FALSE,
'custom_data' => FALSE,
'description' => t('Verifies that a specified field is empty. Recommended use case: Used when want to show'),
),
);
}
But, when I try to use validation on validation rule page, the custom error field shows as required field instead of optional.
Ideally, it should be optional.
Comment | File | Size | Author |
---|---|---|---|
WEBFORM_VALIDATION_TEST.png | 15.44 KB | dineshw |
Comments
Comment #2
Liam MorlandThanks for the report. If you leave out those keys instead of setting them to false it will work. A proper fix is coming.
Comment #4
Liam MorlandTry the development version.
Comment #6
dineshw CreditAttribution: dineshw as a volunteer commentedComment #7
dineshw CreditAttribution: dineshw as a volunteer commented