Commit 6503f3bc authored by Jelle Sebreghts's avatar Jelle Sebreghts
Browse files

added setting whether or not to validate all forms

parent dcb579f5
......@@ -2,7 +2,7 @@
name = Clientside Validation
description = Add client side validation to forms and webforms
core = 7.x
package = Other
package = Clientside Validation
files[] = clientside_validation.module
......
......@@ -99,14 +99,16 @@ function clientside_validation_admin_settings() {
'#type' => 'fieldset',
'#collapsible' => FALSE,
'#collapsed' => FALSE,
'#title' => 'Behaviour for hidden fields',
'#title' => t('Behaviour for hidden fields'),
);
$form['clientside_validation_include_hidden']['clientside_validation_include_hidden'] = array(
'#type' => 'textarea',
'#default_value' => variable_get('clientside_validation_include_hidden', ''),
'#title' => t("Don't ignore hidden fields on the following forms"),
'#description' => t('You can specify form IDs (one per line) of forms that should have hidden elements validated.'),
);
$form['clientside_validation_include_hidden']['clientside_validation_validate_tabs'] = array(
'#type' => 'checkbox',
'#default_value' => variable_get('clientside_validation_validate_tabs', 1),
......@@ -115,6 +117,31 @@ function clientside_validation_admin_settings() {
(including the hidden ones). Warning: if there are other hidden
fields (e.g. conditional fields), those will be validated too.'),
);
$form['clientside_validation_validate_forms'] = array(
'#type' => 'fieldset',
'#collapsible' => FALSE,
'#collapsed' => FALSE,
'#title' => t('Forms to validate'),
);
$form['clientside_validation_validate_forms']['clientside_validation_validate_all'] = array(
'#type' => 'checkbox',
'#default_value' => variable_get('clientside_validation_validate_all', 1),
'#title' => t('Validate all forms'),
);
$form['clientside_validation_validate_forms']['clientside_validation_validate_specific'] = array(
'#type' => 'textarea',
'#default_value' => variable_get('clientside_validation_validate_specific', ''),
'#title' => t("Only validate these specific forms"),
'#description' => t('You can specify form IDs (one per line) of forms that should be validated.'),
'#states' => array(
'invisible' => array(
'input[name="clientside_validation_validate_all"]' => array('checked' => TRUE),
),
),
);
return system_settings_form($form);
}
......@@ -123,6 +150,11 @@ function clientside_validation_admin_settings() {
* Implementation of hook_form_alter().
*/
function clientside_validation_form_alter(&$form, &$form_state, $form_id) {
$validate_specific_setting = variable_get('clientside_validation_validate_specific', '');
$validate_specific = preg_split('/(\r\n?|\n)/', $validate_specific_setting, -1, PREG_SPLIT_NO_EMPTY);
if (!variable_get('clientside_validation_validate_all', 1) && !in_array($form_id, $validate_specific)) {
return;
}
if (strpos($form_id, 'webform_client_form') !== FALSE) {
if (isset($form['actions']['previous'])) {
if (isset($form['actions']['previous']['#attributes'])) {
......
......@@ -2,7 +2,7 @@
name = Clientside Validation FAPI
description = Add client side validation support for <a href="http://www.drupal.org/project/fapi_validation">FAPI Validation</a>
core = 7.x
package = Other
package = Clientside Validation
files[] = clientside_validation_fapi.module
dependencies[] = clientside_validation
......
......@@ -2,7 +2,7 @@
name = Clientside Validation Field Validation
description = Add client side validation support for <a href="http://www.drupal.org/project/field_validation">Field Validation</a>
core = 7.x
package = Other
package = Clientside Validation
files[] = clientside_validation_field_validation.module
dependencies[] = clientside_validation
......
......@@ -2,7 +2,7 @@
name = Clientside Validation Form
description = Add client side validation to regular forms
core = 7.x
package = Other
package = Clientside Validation
files[] = clientside_validation_form.module
dependencies[] = clientside_validation
\ No newline at end of file
......@@ -2,7 +2,7 @@
name = Clientside Validation Webform
description = Add client side validation to webforms
core = 7.x
package = Other
package = Clientside Validation
files[] = clientside_validation_webform.module
dependencies[] = clientside_validation
......
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