Commit 40ac17d3 authored by Jelle Sebreghts's avatar Jelle Sebreghts
Browse files

Centralized the general settings in to one function

parent 81f4ca54
......@@ -127,17 +127,8 @@ function clientside_validation_webform_after_build(&$form, &$form_state) {
$js_rules = array();
drupal_alter("clientside_validation_webform", $form, $form_state, $js_rules);
if (!empty($js_rules)) {
$settings['clientsideValidation']['general'] = array(
"errorClass" => "error",
"wrapper" => "li",
"validateTabs" => variable_get('clientside_validation_validate_tabs', 1),
"scrollTo" => variable_get('clientside_validation_scrollto_errormessage', 1),
"scrollSpeed" => (int)variable_get('clientside_validation_scroll_speed', 1000),
"disableHtml5Validation" => variable_get('clientside_validation_disable_html5', 1),
"validateOnBlur" => variable_get('clientside_validation_validate_onblur', 1),
"validateOnKeyUp" => variable_get('clientside_validation_validate_onkeyup', 1),
"validateOnSubmit" => variable_get('clientside_validation_validate_onsubmit', 1),
);
$settings = array();
_clientside_validation_add_general_settings($settings);
$settings['clientsideValidation']['forms'][$form['#id']]['settings'] = array(
"errorContainer" => "#formerrors-" . $form['#id'],
"errorLabelContainer" => "#formerrors-" . $form['#id'] . " ul",
......@@ -184,17 +175,8 @@ function clientside_validation_form_after_build(&$form, &$form_state) {
drupal_alter("clientside_validation_form", $form, $form_state, $js_rules);
if (!empty($js_rules)) {
$settings['clientsideValidation']['general'] = array(
"errorClass" => "error",
"wrapper" => "li",
"validateTabs" => variable_get('clientside_validation_validate_tabs', 1),
"scrollTo" => variable_get('clientside_validation_scrollto_errormessage', 1),
"scrollSpeed" => (int)variable_get('clientside_validation_scroll_speed', 1000),
"disableHtml5Validation" => variable_get('clientside_validation_disable_html5', 1),
"validateOnBlur" => variable_get('clientside_validation_validate_onblur', 1),
"validateOnKeyUp" => variable_get('clientside_validation_validate_onkeyup', 1),
"validateOnSubmit" => variable_get('clientside_validation_validate_onsubmit', 1),
);
$settings = array();
_clientside_validation_add_general_settings($settings);
$settings['clientsideValidation']['forms'][$form['#id']]['settings'] = array(
"errorContainer" => "#formerrors-" . $form['#id'],
"errorLabelContainer" => "#formerrors-" . $form['#id'] . " ul",
......@@ -230,6 +212,20 @@ function clientside_validation_form_after_build(&$form, &$form_state) {
return $form;
}
function _clientside_validation_add_general_settings(&$settings) {
$settings['clientsideValidation']['general'] = array(
"errorClass" => "error",
"wrapper" => "li",
"validateTabs" => variable_get('clientside_validation_validate_tabs', 1),
"scrollTo" => variable_get('clientside_validation_scrollto_errormessage', 1),
"scrollSpeed" => (int)variable_get('clientside_validation_scroll_speed', 1000),
"disableHtml5Validation" => variable_get('clientside_validation_disable_html5', 1),
"validateOnBlur" => variable_get('clientside_validation_validate_onblur', 1),
"validateOnKeyUp" => variable_get('clientside_validation_validate_onkeyup', 1),
"validateOnSubmit" => variable_get('clientside_validation_validate_onsubmit', 1),
);
}
/**
* Set validation rule for required fields.
*/
......
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