Problem/Motivation

Due to issues with jQuery validation, the number of forms that this module causes to break on our site is not insignificant. We could use the "Clientside Validation Enabled Forms" field if we choose to deselect the "Use Clientside Validation in all forms" checkbox. When dealing with a site of the complexity of ours, however, the number of forms we would have to explicitly identify to have the module validate would be significant. This configuration could go out of date when new entity types are added.

Thus, it would be ideal to be able to create two "Exceptions" form elements.

  1. One could be for field exceptions to be available whether validation runs on all or only specific forms
  2. One could be for form exceptions when "Use Clientside Validation in all forms" is checked

Proposed resolution

  • A "Field exceptions" textfield added to the configuration form (`/admin/config/user-interface/clientside-validation`) and is always visible. Any field name added to the "Field exceptions" field, with one field name per line, results in the module not validating that field
  • A "Form exceptions" textfield added to the configuration form (`/admin/config/user-interface/clientside-validation`), visible when "Use Clientside Validation in all forms" is checked. Any form id added to the "Form exceptions" field, with one form id per line, results in the module not validating that form.

User interface changes

Screenshot of Clientside Validation configuration with enabled forms field showing

  • The "Field exceptions" textfield would be visible.
  • The "Field exceptions" field should have help text that describes the purpose.

Screenshot of Clientside Validation configuration with enabled forms field showing

  • The "Form exceptions" textfield would be visible when the "Use Clientside Validation in all forms" is checked.
  • The "Form exceptions" field should have help text that describes the purpose.
  • Should there be data in the "Form exceptions" textfield when the "Use Clientside Validation in all forms" is unchecked, that data should be removed when the configuration form is saved.

Implementation steps

  • The config/schema/clientside_validation.schema.yml would need to be updated to add the two new config fields data mapping.
  • The src/Form/ClientsideValidationSettingsForm.php would need to be updated to add the form fields.
  • The clientside_validation.module would need to be updated.
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

skyriter created an issue. See original summary.

skyriter’s picture

Issue summary: View changes
skyriter’s picture

Issue summary: View changes
StatusFileSize
new231.62 KB
new210.99 KB
skyriter’s picture

Issue summary: View changes
swirt’s picture

I like this idea very much. There have been a couple of sites I wanted to use this on, but validation was too greedy and broke a few forms. This addition would make it more useable for my use cases.

skyriter’s picture

Title: Add a configuration option for exceptions to all forms selection » Add a configuration option for exceptions

skyriter’s picture

This issue was written without an understanding of what was already being done in https://www.drupal.org/project/clientside_validation/issues/2949540.

As a result, I added code over there to satisfy the need to both include and exclude forms.

I think now that this issue would be better scoped to only exclude fields (though having spent some time trying to do just that, I am stumped on how to do it).