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.
In line 159 of webform_validation.module you compare to WEBFORM_CONDITIONAL_INCLUDE this constant is not set in the 7.x-3.x version off webform, it appears to be added to the 7.x-4.x branch. When attempting to validate a field with regex or pattern and I suspect any validator on receives the notice:
Notice: Use of undefined constant WEBFORM_CONDITIONAL_INCLUDE - assumed 'WEBFORM_CONDITIONAL_INCLUDE' in webform_validation_validate() (line 159 of /v...
To fix this I added the following just bellow your includes:
<?php
/**
* Add check for WEBFORM_CONDITIONAL_INCLUDE and define if needed.
*/
if (!defined('WEBFORM_CONDITIONAL_INCLUDE')) {
define('WEBFORM_CONDITIONAL_INCLUDE', 1);
}
?>
Comment | File | Size | Author |
---|---|---|---|
#9 | webform_validation-WEBFORM_CONDITIONAL_INCLUDE_in_wf3-2417015-9-D7.patch | 1.17 KB | Liam Morland |
#1 | undefined_constant-2417015-1.patch | 499 bytes | undertext |
Comments
Comment #1
undertext CreditAttribution: undertext commentedHere is the patch with the same code fix.
Comment #2
Liam MorlandIf that constant isn't there, does _webform_client_form_rule_check() still behave the same way? It looks like it returns a Boolean. That will require a more elaborate change to make it work properly.
I am inclined to drop support for Webform 3 if supporting it means significant separate code paths.
Comment #3
Liam MorlandThis problem was introduced by #2348403: Do not validates components hidden by conditional actions.
Comment #4
Liam MorlandComment #5
Liam MorlandA potentially better approach: Check of WEBFORM_CONDITIONAL_INCLUDE exists. If it does, behave like now, otherwise, behave based on the output of _webform_client_form_rule_check() from Webform 3 (I think it is boolean).
Comment #6
fabiobosio CreditAttribution: fabiobosio commentedHi to all,
I put the code in the module , "webform_validation.module", but the error still persists.
Someone can help me?
Fabio
Comment #7
hedroom CreditAttribution: hedroom commentedIt seems that webform 3.x does not use these constants at all. So wouldn't be better to just define them at the top of the webform.module file like they are in 4.x?
I added:
at the top of webform.module and that fixed the problem for me.
Looking at the function _webform_client_form_rule_check(), it looks like this should work properly...
Wade
Comment #8
Liam MorlandWe don't want to get rid of the error, but break validation at the same time.
In Webform 4, _webform_client_form_rule_check() returns an integer. In Webform 3, it returns a Boolean, so it will never match any of the WEBFORM_CONDITIONAL_* constants. The comparison is made with "!==", so the type needs to match too.
Maybe casting the return value of _webform_client_form_rule_check() to integer would work as part of the solution.
Comment #9
Liam MorlandPlease try this patch.
Comment #11
Liam Morland