When I export my field validation rules to features, I end up with this error.
Warning: Invalid argument supplied for foreach() in element_children() (line 6288 of /Users/jucallme/Sites/systemseed/concern/7.x-1.x/build/includes/common.inc
that is called from clientside_validation_field_validation.module [line] => 30
Here is the export of one of the rules.
/**
* Implements hook_default_field_validation_rule().
*/
function MY_FEATURE_MODULE_default_field_validation_rule() {
$export = array();
$rule = new stdClass();
$rule->disabled = FALSE; /* Edit this to true to make a default rule disabled initially */
$rule->api_version = 2;
$rule->rulename = 'First name can only contain alphabetic characters.';
$rule->name = 'first_name_alpha_billing';
$rule->field_name = 'field_cw_profile_firstname';
$rule->col = 'value';
$rule->entity_type = 'commerce_customer_profile';
$rule->bundle = 'billing';
$rule->validator = 'field_validation_regex_validator';
$rule->settings = array(
'data' => '^[a-zA-Z]*$',
'errors' => 0,
);
$rule->error_message = 'First name can only contain alphabetic characters.';
$export['first_name_alpha_billing'] = $rule;
return $export;
}
Comments
Comment #1
attiks commentedThis sounds like a problem with field validation? Or goes the problem wawy if you disable clientside_validation?
Comment #2
roam2345 commentedopened ticket against field_validation http://drupal.org/node/1778002
Comment #3
roam2345 commentedI have narrowed it down to this line.
Comment #4
mrfelton commentedI think the problem may be a problem with commerce, where the fields lay deeper within the form array (within individual checkout panes), and not at the top level of the form as with more standard entity forms. On line 23 of clientside_validation_field_validation.module, you call
$element = &$element[$rule['rule']['field_name']];:Comment #5
mrfelton commentedAttached patch sort of fixes the problem, in that the errors go away, and validation continues to work normally on standard entity forms. But now, in the case of commerce, the validations seem messed up (wrong element validating against wrong rules).
Comment #6
attiks commentedComment #7
qasimzee commentedsubscribing
Comment #8
roam2345 commentedHere is a patch that correctly traverses the form and finds the elements (it now does not matter where they hide).
Comment #9
roam2345 commentedchange the status on this.
Comment #10
roam2345 commentedfixed small issue with patch moved validation calls inside path check.
Comment #11
jelle_sAfter applying this patch I get a fatal error going to a form with (admittedly quite a lot of) field validation rules:
Comment #12
roam2345 commentedNow limiting the recursive search to 3 levels of the array, assume 3 should be sufficient.
Comment #13
roam2345 commentedstatus change
Comment #14
cellar door commentedThis worked for me with an issue I was having with Profile2reg and Field Validation. I had a text field validated w/ regex and it was causing this error but after this patch it worked. Patch didn't apply cleanly but that's probably because it's against dev. Either way it's functioning now.
Thanks!
Comment #15
mrfelton commentedUpdated to work with latest codebase
Comment #16
attiks commentedCommitted to latest dev version, thanks
Comment #17
jelle_sComment #18.0
(not verified) commentedmore context