function clientside_validation_settings_load in Clientside Validation 7
Same name and namespace in other branches
- 7.2 clientside_validation.module \clientside_validation_settings_load()
4 calls to clientside_validation_settings_load()
- clientside_validation_form_alter in ./
clientside_validation.module - Implements hook_form_alter().
- clientside_validation_settings_form in ./
clientside_validation.admin.inc - clientside_validation_settings_load_defaults in ./
clientside_validation.module - clientside_validation_settings_overview in ./
clientside_validation.admin.inc
File
- ./
clientside_validation.module, line 1532 - Add client side validation to forms.
Code
function clientside_validation_settings_load($cvs_type = NULL, $cvs_formid = NULL, $include_disabled = FALSE) {
$default_settings = array(
'validate_options' => array(
'disable_html5' => 1,
'validate_onsubmit' => 1,
'validate_onblur' => 1,
'validate_onblur_always' => 0,
'validate_onkeyup' => 1,
'validate_before_ajax' => 0,
'show_messages' => 0,
'captcha' => 1,
),
'error' => array(
'prefix' => '',
'suffix' => '',
'scrollto_errormessage' => 1,
'scroll_speed' => 1000,
'error_element' => 'label',
),
'error_placement' => array(
'error_placement_default' => CLIENTSIDE_VALIDATION_TOP_OF_FORM,
'jquery_selector' => '',
'custom_error_function' => '',
),
'include_hidden' => array(
'include_hidden' => '',
'include_hidden_fields' => FALSE,
'validate_tabs' => '',
),
);
if ($cvs_type == 'default') {
return drupal_array_merge_deep($default_settings, variable_get('clientside_validation_default_settings', $default_settings));
}
if (!db_table_exists('clientside_validation_settings')) {
drupal_set_message(t("You need to run the database update script so that Clientside Validation can function properly. Click !here to run the database update script.", array(
'!here' => l('here', 'update.php'),
)), 'error');
return variable_get('clientside_validation_default_settings', $default_settings);
}
$query = db_select('clientside_validation_settings')
->fields('clientside_validation_settings');
if (!empty($cvs_type)) {
$query
->condition('type', $cvs_type);
}
if (!empty($cvs_formid)) {
$query
->condition('form_id', $cvs_formid);
}
if (!$include_disabled) {
$query
->condition('status', 1);
}
$result = $query
->execute();
// a single id was given -> one result, so only return one row
if (isset($cvs_formid)) {
$res = $result
->fetchAssoc();
if ($res) {
$res['settings'] = unserialize($res['settings']);
$res['settings'] = drupal_array_merge_deep(clientside_validation_settings_load_defaults(), $res['settings']);
}
else {
$res['settings'] = clientside_validation_settings_load_defaults();
}
return $res;
}
$res = $result
->fetchAllAssoc('form_id');
if ($res) {
foreach ($res as &$setting) {
$setting->settings = unserialize($setting->settings);
$setting->settings = drupal_array_merge_deep(clientside_validation_settings_load_defaults(), $setting->settings);
}
}
return $res;
}