Commit 7d01cee4 authored by Jelle Sebreghts's avatar Jelle Sebreghts
Browse files

Issue #1765636 by solotandem: Fixed Undefined index: #required in clientside_validation_regular().

parent 0624b42a
......@@ -83,8 +83,13 @@ function clientside_validation_field_validation_after_build_recurse($form_id, &$
}
function clientside_validation_field_validation_regular($form_id, $element, $rule, &$js_rules) {
if ($rule['api_version'] >= 2 && strpos($element['#name'], $rule['col']) === FALSE) {
return;
if (isset($rule['col']) && $rule['col'] === 'value') {
if (strpos($element['#name'], '[format]') === strlen($element['#name']) - strlen('[format]')) {
return;
}
if (strpos($element['#name'], '[summary]') === strlen($element['#name']) - strlen('[summary]')) {
return;
}
}
$el_name = $element['#name'];
if (isset($element['#multiple']) && $element['#multiple']) {
......
......@@ -64,12 +64,12 @@ function clientside_validation_regular($form_id, $element, &$js_rules, $form_sta
if ($is_multiple) {
// Only first field is required
if (!isset($multiples[$form_id][$el_name])) {
_clientside_validation_set_required($el_name, $el_title, $element['#required'], $js_rules, $required_error);
_clientside_validation_set_required($el_name, $el_title, isset($element['#required']) ? $element['#required'] : FALSE, $js_rules, $required_error);
$multiples[$form_id][$el_name] = 1;
}
}
else {
_clientside_validation_set_required($el_name, $el_title, $element['#required'], $js_rules, $required_error);
_clientside_validation_set_required($el_name, $el_title, isset($element['#required']) ? $element['#required'] : FALSE, $js_rules, $required_error);
}
if (isset($element['#maxlength']) && $element['#maxlength'] > 0) {
_clientside_validation_set_minmaxlength($el_name, $el_title, '', $element['#maxlength'], $js_rules);
......@@ -131,7 +131,7 @@ function clientside_validation_regular($form_id, $element, &$js_rules, $form_sta
}
_clientside_validation_set_minmaxlength($el_name, $el_title, $min, $max, $js_rules);
}
_clientside_validation_set_required($el_name, $el_title, $element['#required'], $js_rules, $required_error);
_clientside_validation_set_required($el_name, $el_title, isset($element['#required']) ? $element['#required'] : FALSE, $js_rules, $required_error);
if ($element['#required']) {
// @see http://drupal.org/node/1585554
$error = isset($js_rules[$el_name]['messages']['required']) ? $js_rules[$el_name]['messages']['required'] : NULL;
......@@ -140,7 +140,7 @@ function clientside_validation_regular($form_id, $element, &$js_rules, $form_sta
break;
case 'radio':
case 'radios':
_clientside_validation_set_required($el_name, $el_title, $element['#required'], $js_rules, $required_error);
_clientside_validation_set_required($el_name, $el_title, isset($element['#required']) ? $element['#required'] : FALSE, $js_rules, $required_error);
break;
case 'checkbox':
case 'checkboxes':
......@@ -156,8 +156,8 @@ function clientside_validation_regular($form_id, $element, &$js_rules, $form_sta
}
_clientside_validation_set_checkboxgroup_minmax($element['#name'], $el_title, $id, $js_rules, $required_error, 1, $max);
}
elseif ($element['#required']) {
_clientside_validation_set_required($el_name, $el_title, $element['#required'], $js_rules, $required_error);
else {
_clientside_validation_set_required($el_name, $el_title, isset($element['#required']) ? $element['#required'] : FALSE, $js_rules, $required_error);
}
break;
case 'link_field':
......@@ -170,14 +170,14 @@ function clientside_validation_regular($form_id, $element, &$js_rules, $form_sta
foreach(element_children($element['hierarchical_select']['selects']) as $child) {
if ($element['#config']['enforce_deepest'] || $child < 1) {
$child_name = $element['hierarchical_select']['selects'][$child]['#name'];
_clientside_validation_set_required($child_name, $el_title, $element['#required'], $js_rules, $required_error);
_clientside_validation_set_required($child_name, $el_title, isset($element['#required']) ? $element['#required'] : FALSE, $js_rules, $required_error);
if ($element['#required']) {
$error = isset($js_rules[$child_name]['messages']['required']) ? $js_rules[$child_name]['messages']['required'] : NULL;
_clientside_validation_set_blacklist($child_name, $el_title, array('label_' . $child, 'none', '_none'), $js_rules, $error);
}
}
}
_clientside_validation_set_required($el_name, $el_title, $element['#required'], $js_rules, $required_error);
_clientside_validation_set_required($el_name, $el_title, isset($element['#required']) ? $element['#required'] : FALSE, $js_rules, $required_error);
break;
case 'checkbox_tree':
if ($element['#required']) {
......@@ -188,16 +188,12 @@ function clientside_validation_regular($form_id, $element, &$js_rules, $form_sta
case 'date_text':
$date_title = ($element['#type'] == 'date_popup') ? $element['date']['#title'] : $element['#date_title'];
if (isset($element['date'])) {
if ($element['#required']) {
_clientside_validation_set_required($element['date']['#name'], $date_title, $element['#required'], $js_rules);
}
_clientside_validation_set_required($element['date']['#name'], $date_title, isset($element['#required']) ? $element['#required'] : FALSE, $js_rules);
$format = date_popup_date_format($element);
_clientside_validation_set_date($element['date']['#name'], $date_title, $format, $js_rules);
}
if (isset($element['time']) && isset($element['time']['#name'])) {
if ($element['#required']) {
_clientside_validation_set_required($element['time']['#name'], $element['time']['#title'], $element['#required'], $js_rules);
}
_clientside_validation_set_required($element['time']['#name'], $element['time']['#title'], isset($element['#required']) ? $element['#required'] : FALSE, $js_rules);
}
break;
case 'captcha':
......@@ -210,8 +206,8 @@ function clientside_validation_regular($form_id, $element, &$js_rules, $form_sta
}
break;
}
if (!isset($js_rules[$el_name]['required']) && $element['#required']) {
_clientside_validation_set_required($el_name, $el_title, $element['#required'], $js_rules, $required_error);
if (!isset($js_rules[$el_name]['required'])) {
_clientside_validation_set_required($el_name, $el_title, isset($element['#required']) ? $element['#required'] : FALSE, $js_rules, $required_error);
}
}
}
......
......@@ -54,7 +54,7 @@ function clientside_validation_html5($form_id, $element, &$js_rules) {
$element['#required'] = TRUE;
}
$required_error = isset($element['#required_error']) ? $element['#required_error'] : '';
_clientside_validation_set_required($el_name, $el_title, $element["#required"], $js_rules, $required_error);
_clientside_validation_set_required($el_name, $el_title, isset($element['#required']) ? $element['#required'] : FALSE, $js_rules, $required_error);
if (isset($element['#pattern'])) {
_clientside_validation_set_regex($el_name, $el_title, $js_rules, $element['#pattern']);
}
......
......@@ -29,17 +29,17 @@ function clientside_validation_webform_after_build_recurse($form_id, &$form, &$f
if (isset($element['#type'])) {
if (isset($element['#webform_component']) && $element['#webform_component']['type'] == 'time' && isset($element['hour']['#name'])) {
$message = t('Hour in !name field is required.', array('!name' => variable_get('clientside_validation_prefix', '') . $element['#title'] . variable_get('clientside_validation_suffix', '')));
_clientside_validation_set_required($element['hour']['#name'], $element['#title'], $element['#required'], $js_rules, $message);
_clientside_validation_set_required($element['hour']['#name'], $element['#title'], isset($element['#required']) ? $element['#required'] : FALSE, $js_rules, $message);
$message = t('Minute in !name field is required.', array('!name' => variable_get('clientside_validation_prefix', '') . $element['#title'] . variable_get('clientside_validation_suffix', '')));
_clientside_validation_set_required($element['minute']['#name'], $element['#title'], $element['#required'], $js_rules, $message);
_clientside_validation_set_required($element['minute']['#name'], $element['#title'], isset($element['#required']) ? $element['#required'] : FALSE, $js_rules, $message);
}
elseif (isset($element['#webform_component']) && $element['#webform_component']['type'] == 'date') {
$message = t('Month in !name field is required.', array('!name' => variable_get('clientside_validation_prefix', '') . $element['#title'] . variable_get('clientside_validation_suffix', '')));
_clientside_validation_set_required($element['#name'] . '[month]', $element['#title'], $element['#required'], $js_rules, $message);
_clientside_validation_set_required($element['#name'] . '[month]', $element['#title'], isset($element['#required']) ? $element['#required'] : FALSE, $js_rules, $message);
$message = t('Day in !name field is required.', array('!name' => variable_get('clientside_validation_prefix', '') . $element['#title'] . variable_get('clientside_validation_suffix', '')));
_clientside_validation_set_required($element['#name'] . '[day]', $element['#title'], $element['#required'], $js_rules, $message);
_clientside_validation_set_required($element['#name'] . '[day]', $element['#title'], isset($element['#required']) ? $element['#required'] : FALSE, $js_rules, $message);
$message = t('Year in !name field is required.', array('!name' => variable_get('clientside_validation_prefix', '') . $element['#title'] . variable_get('clientside_validation_suffix', '')));
_clientside_validation_set_required($element['#name'] . '[year]', $element['#title'], $element['#required'], $js_rules, $message);
_clientside_validation_set_required($element['#name'] . '[year]', $element['#title'], isset($element['#required']) ? $element['#required'] : FALSE, $js_rules, $message);
if (isset($element['#year_start']) && isset($element['#year_end'])) {
if (is_numeric($element['#year_start']) && is_numeric($element['#year_end'])) {
$message = t('The entered date needs to be between the years @start and @end.', array('@start' => $element['#year_start'], '@end' => $element['#year_end']));
......@@ -71,10 +71,10 @@ function clientside_validation_webform_after_build_recurse($form_id, &$form, &$f
_clientside_validation_set_checkboxgroup_minmax($element['#name'], $element['#title'], $id, $js_rules, '', intval($element['#required']));
}
elseif ($element['#type'] == 'select' && $element['#multiple']) {
_clientside_validation_set_required($element['#name'] . '[]', $element['#title'], $element['#required'], $js_rules);
_clientside_validation_set_required($element['#name'] . '[]', $element['#title'], isset($element['#required']) ? $element['#required'] : FALSE, $js_rules);
}
elseif (isset($element['#name'])) {
_clientside_validation_set_required($element['#name'], $element['#title'], $element['#required'], $js_rules);
_clientside_validation_set_required($element['#name'], $element['#title'], isset($element['#required']) ? $element['#required'] : FALSE, $js_rules);
}
}
if (isset($element['#webform_component']) && $element['#webform_component']['type'] == 'file') {
......@@ -84,7 +84,7 @@ function clientside_validation_webform_after_build_recurse($form_id, &$form, &$f
$file_child = $element[$child];
if (isset($file_child['#name']) && $file_child['#type'] == 'file') {
$name = $file_child['#name'];
_clientside_validation_set_required($name, $element['#title'], (bool)$element['#webform_component']['mandatory'], $js_rules);
_clientside_validation_set_required($name, $element['#title'], isset($element['#webform_component']['mandatory']) ? (bool)$element['#webform_component']['mandatory'] : FALSE, $js_rules);
if (isset($element['#webform_component']['extra']['filtering']['types'])) {
$extensions = $element['#webform_component']['extra']['filtering']['types'];
_clientside_validation_set_extensions($name, $extensions, $js_rules);
......
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