Comments

attiks created an issue. See original summary.

Jelle_S’s picture

How do we figure out which js files should be attached?

For example:
if this submodule is enabled, it should attach the jQuery Validate library.
Contrib might define some custom validation methods that are in different js files.

Contrib can use \Drupal::moduleHandler()->moduleExists($module); to determine what validation plugin module is enabled to determine which js file to add.

Should we:

  1. Use a custom hook, and just pass the entire form and let contrib figure out what files to attach (meaning they probably have to recursively loop the form).
  2. Use some sort of plugins (that have a @supports annotation, stating which js validation library and which validation plugin they support), same way we do now to attach the data attributes
  3. Use a custom hook we fire on each element (since we're looping through them recursively anyway)
  4. Use a custom hook we fire on each Validator plugin we find (cfr. 2.)
  5. Let contrib use hook_clientside_validation_validator_info_alter to specify which js files to add in the plugin definition of each plugin.
Jelle_S’s picture

5. Let contrib use hook_clientside_validation_validator_info_alter to specify which js files to add in the plugin definition of each plugin.

  • Jelle_S committed c1d6cd9 on 8.x-1.x
    Issue #2611524: Add sub module for jquery validate
    

  • Jelle_S committed f925093 on 8.x-1.x
    Issue #2611524: Add sub module for jquery validate
    
attiks’s picture

Can we add a line in the status report for installing the lib

attiks’s picture

and maybe add a readme

Jelle_S’s picture

Assigned: Unassigned » attiks
Status: Active » Needs review

Not sure if the status report is still needed since we use a cdn version if the lib is not installed. Readme was added a while ago too.

attiks’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.