Commit 18eb0b67 authored by Jelle Sebreghts's avatar Jelle Sebreghts
Browse files

fix for #1239192 and #1239128. Special thanks to mjpa

parent 6860f59a
......@@ -5,6 +5,9 @@
Drupal.myClientsideValidation = new Drupal.clientsideValidation();
}
else {
// Update the settings
Drupal.myClientsideValidation.data = Drupal.settings.clientsideValidation;
Drupal.myClientsideValidation.forms = Drupal.myClientsideValidation.data['forms'];
Drupal.myClientsideValidation.bindForms();
}
}
......@@ -138,10 +141,10 @@
}
};
if (!Drupal.settings.clientsideValidation.forms[f].includeHidden) {
if (!self.forms[f].includeHidden) {
validate_options.ignore = ':input:hidden';
}
if(Drupal.settings.clientsideValidation.general.validateTabs) {
if(self.data.general.validateTabs) {
validate_options.ignore += ' :not(.vertical-tabs-pane:input)';
}
self.validators[f] = $('#' + f).validate(validate_options);
......
......@@ -235,6 +235,11 @@ function clientside_validation_webform_after_build(&$form, &$form_state) {
*/
function clientside_validation_form_after_build(&$form, &$form_state) {
static $js_rules = array();
static $form_ids = array();
if (isset($form_ids[$form['#id']])) {
return $form;
}
drupal_alter("clientside_validation_form", $form, $form_state, $js_rules);
if (!empty($js_rules)) {
$settings['clientsideValidation']['general'] = array(
......@@ -270,6 +275,7 @@ function clientside_validation_form_after_build(&$form, &$form_state) {
}
drupal_add_js(drupal_get_path('module', 'clientside_validation') . '/clientside_validation.js');
drupal_add_js($settings, 'setting');
$form_ids[$form['#id']] = TRUE;
}
return $form;
......
......@@ -15,7 +15,7 @@ function clientside_validation_form_after_build_recurse($form_id, &$form, &$form
foreach ($children as $index => $item) {
$element = &$form[$item];
$types = array(
'textfield', 'textarea', 'select', 'radio', 'checkbox', 'password', 'file', 'radios', 'checkboxes',
'textfield', 'textarea', 'select', 'radio', 'checkbox', 'password', 'managed_file', 'file', 'radios', 'checkboxes',
);
if (isset($element['#type']) && in_array($element['#type'], $types)) {
clientside_validation_regular($form_id, $element, $js_rules);
......@@ -42,6 +42,11 @@ function clientside_validation_regular($form_id, $element, &$js_rules) {
case 'password':
case 'textarea':
case 'file':
case 'managed_file':
if ($element['#type'] == 'managed_file') {
$el_name = $element['upload']['#name'];
}
if ($is_multiple) {
// Only first field is required
if (!isset($multiples[$form_id][$el_name])) {
......@@ -84,4 +89,4 @@ function clientside_validation_regular($form_id, $element, &$js_rules) {
break;
}
}
}
\ No newline at end of file
}
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