alleyinteractive / wordpress-fieldmanager

Custom field types for WordPress
Other
532 stars 101 forks source link

jQuery Validator issues with repeaters #843

Open simonrcodrington opened 2 years ago

simonrcodrington commented 2 years ago

Hi

I've noticed when using repeaters ('limit' = 0) that there are validation issues when using the 'validation_rules' functionality. For example if you have a single field that is repeater (a text field) and apply basic validation like 'required' and minlength , the validation wont work on new items.

For example if you add an initial item the validation will work, however if you add subsequent items the validation doesn't trigger. See the image below where the first item works fine but subsequent ones do not

image

It's super inconsistent. After reloading the page, sometimes the validation for the first item wont work, but it will for the second item. See for example the image below where the validation for the first item is now lost

image

Here is how I'm setting up this repeater

image

I'm using version 1.2.5 which is an older version, is this something that's been fixed in newer versions?

theMikeD commented 1 year ago

I've seen the same thing in 1.5.0.

My console message is

An invalid form control with name='option[manifests][premium][proto][key]' is not focusable.

So it's looking for

option[manifests][premium][proto][key]

but the element's name attribute is

option[manifests][premium][0][key]