Discovered in #1462410: Clientside validation is not working properly with file component upload button:
If you have a form with a multiple value email field., the first field has email validation, but when you then click "Add more items", those fields don't get validated by CV.

After digging around a bit I found what is causing this. Although I'm not sure yet how to fix it.
We add the settings we pass to javascript in an array keyed with the form's HTML id attribute:

$settings['clientsideValidation']['forms'][$form['#id']]['rules'][$key] = $rule;

The problem here is that, for some reason, on an AJAX callback, drupal changes the value in $form['#id'] of the exact same form to something else.

For example: If I have a form that on the first page load that has $form['#id'] = 'my-form-id', it will have 'my-form-id--2' after an AJAX callback. The HTML id attribute won't be changed in the HTML and CV will have separate js settings for each form id. But since the form with id 'my-form-id--2' doesn't exist, the old settings (that don't include the new field) will still be used. I'm not sure what the right approach is for fixing this...

Comments

Jelle_S’s picture

Fixed in latest dev version.

We do a check if the form id end with --{number} and remove it if it does, so the settings are added to the right form.

Jelle_S’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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