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:
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).
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
Use a custom hook we fire on each element (since we're looping through them recursively anyway)
Use a custom hook we fire on each Validator plugin we find (cfr. 2.)
Let contrib use hook_clientside_validation_validator_info_alter to specify which js files to add in the plugin definition of each plugin.
Comments
Comment #2
jelle_sHow 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:
hook_clientside_validation_validator_info_alterto specify which js files to add in the plugin definition of each plugin.Comment #3
jelle_s5. Let contrib use
hook_clientside_validation_validator_info_alterto specify which js files to add in the plugin definition of each plugin.Comment #6
attiks commentedCan we add a line in the status report for installing the lib
Comment #7
attiks commentedand maybe add a readme
Comment #8
jelle_sNot 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.
Comment #9
attiks commented