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

Issue #1355546 by torbeng: Fixed Undefined variable.

parent cf5e3705
......@@ -15,6 +15,7 @@
if (update) {
Drupal.myClientsideValidation.data = Drupal.settings.clientsideValidation;
Drupal.myClientsideValidation.forms = Drupal.myClientsideValidation.data['forms'];
Drupal.myClientsideValidation.groups = Drupal.myClientsideValidation.data.groups;
Drupal.myClientsideValidation.bindForms();
}
}
......@@ -27,7 +28,7 @@
this.data = Drupal.settings.clientsideValidation;
this.forms = this.data['forms'];
this.validators = {};
this.groups = {};
this.groups = this.data['groups'];
//disable class and attribute rules
$.validator.classRules = function() {
......@@ -62,7 +63,6 @@
jQuery.each (self.forms, function(f) {
var errorel = self.prefix + f + '-errors';
self.groups[f] = {};
// Remove any existing validation stuff
if (self.validators[f]) {
// Doesn't work :: $('#' + f).rules('remove');
......
......@@ -110,15 +110,7 @@ function clientside_validation_form_alter(&$form, &$form_state, $form_id) {
if (isset($form['actions']['delete'])) {
$form['actions']['delete']['#attributes']['class'][] = 'cancel';
}
switch ($form['#id']) {
case 'node-form':
case 'webform-component-edit-form':
$form['#after_build'][] = 'clientside_validation_form_after_build';
break;
default:
$form['#after_build'][] = 'clientside_validation_form_after_build';
break;
}
$form['#after_build'][] = 'clientside_validation_form_after_build';
}
}
......@@ -148,6 +140,13 @@ function clientside_validation_webform_after_build(&$form, &$form_state) {
}
function _clientside_validation_add_special_rules(&$js_rules, &$settings, $form) {
if (isset($js_rules['_groups'])) {
$settings['clientsideValidation']['groups'][$form['#clientside_validation_id']] = $js_rules['_groups'];
unset($js_rules['_groups']);
}
else {
$settings['clientsideValidation']['groups'][$form['#clientside_validation_id']] = array();
}
foreach ($js_rules as $key => $rule) {
if (isset($rule['checkboxgroupminmax'])) {
$settings['clientsideValidation']['forms'][$form['#id']]['checkboxrules'][$key] = array(
......
......@@ -101,6 +101,7 @@ function clientside_validation_webform_after_build_recurse($form_id, &$form, &$f
function clientside_validation_webform_add_webform_validation($form_id, &$form, &$form_state, &$js_rules) {
if ($webform_validation_rules = _clientside_validation_webform_webform_validation($form_state['values']['details']['nid'], $form)) {
$checkboxrules = array();
foreach ($webform_validation_rules as $webform_validation_rule) {
switch ($webform_validation_rule['validator']) {
case 'min_length':
......@@ -226,14 +227,16 @@ function clientside_validation_webform_add_webform_validation($form_id, &$form,
break;
}
}
foreach ($checkboxrules as $name => $args) {
if (!isset($args['min'])) {
$args['min'] = 1;
}
if (!isset($args['max'])) {
$args['max'] = 99;
if (!empty($checkboxrules)) {
foreach ($checkboxrules as $name => $args) {
if (!isset($args['min'])) {
$args['min'] = 1;
}
if (!isset($args['max'])) {
$args['max'] = 99;
}
_clientside_validation_set_checkboxgroup_minmax($name, $args['title'], $args['id'], $js_rules, '', $args['min'], $args['max']);
}
_clientside_validation_set_checkboxgroup_minmax($name, $args['title'], $args['id'], $js_rules, '', $args['min'], $args['max']);
}
}
}
......
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