Commit a4d76661 authored by Jelle Sebreghts's avatar Jelle Sebreghts
Browse files

Issue #1543742 by peskydonut: Added Custom validation using #element_validate().

parent 46b3a3b9
......@@ -12,12 +12,16 @@ function clientside_validation_form_after_build_recurse($form_id, &$form, &$form
if ($children = array_values(element_children($form))) {
foreach ($children as $index => $item) {
$element = &$form[$item];
/* $types = array(
$types = array(
'textfield', 'textarea', 'select', 'radio', 'checkbox', 'password', 'managed_file', 'file', 'radios', 'checkboxes', 'link_field',
);*/
if (isset($element['#type']) /*&& in_array($element['#type'], $types)*/) {
);
if (isset($element['#type']) && in_array($element['#type'], $types)) {
clientside_validation_regular($form_id, $element, $js_rules, $form_state);
}
if (isset($element['#element_validate']) && !empty($element['#element_validate'])) {
$context = array('type' => 'element_validate', 'functions' => $element['#element_validate']);
drupal_alter('clientside_validation_rule', $js_rules, $element, $context);
}
clientside_validation_form_after_build_recurse($form_id, $element, $form_state, $js_rules);
}
}
......@@ -156,10 +160,6 @@ function clientside_validation_regular($form_id, $element, &$js_rules, $form_sta
break;
}
}
if (isset($element['#element_validate']) && !empty($element['#element_validate'])) {
$context = array('type' => 'element_validate', 'functions' => $element['#element_validate']);
drupal_alter('clientside_validation_rule', $js_rules, $element, $context);
}
}
function clientside_validation_form_field_info_alter(&$info) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment