There will be cases where we want to handle the form submission in custom way, do some custom validations or AJAX / API calls before doing the form submit. Here if we bind the submit event of form clientside validation is not invoked.
To fix this, we can allow custom submit handler to be called in submitHandler of validate().
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | cv_custom.tar_.gz | 1.02 KB | jelle_s |
| #9 | 2898885-9.patch | 1.07 KB | nikunjkotecha |
Issue fork clientside_validation-2898885
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
Comment #2
nikunjkotechaComment #4
nikunjkotechaFix for build failure and additional fix to allow other modules to destroy validator using objects stored in Drupal.cvValidatorObjects.
Comment #6
nikunjkotechaComment #7
nikunjkotechaComment #9
nikunjkotechaRemoved the changed related to composer.json inside module. This will be handled separately in https://www.drupal.org/node/2784069 or some other ticket.
Comment #10
jelle_sI'm not sure we need this functionality?
Developers can add their own submit handler to their forms in their js files like this:
Comment #11
nikunjkotecha@Jelle_S It was not updating after it's initiated once
Comment #12
jelle_sAh, strange. I'll try to create a proof of concept later on. If I can get it to work fairly simple, I'll add the method to the readme. If not, I'll have another look at the patch.
Comment #13
nikunjkotechaI think if we only add Drupal.cvValidatorObjects or something to store all objects, it would allow other modules to modify settings. Submit handler being more common case I added in module js itself.
Comment #14
jelle_sAttached is a proof of concept that works for me (latest dev version of clientside validation 8.x-1.x. Can you confirm it works for you too?
If it does we might want to document this.
Comment #15
nikunjkotecha@Jelle_S this works fine, I'll spend sometime tonight to create a documentation page from the code sample you shared :)
I see where I was missing, I was trying to use validate() with options again to bind the submit function.
Comment #16
nikunjkotecha