Validation not working for Select Multiple in custom form


(Evan Wills) #1

I have a custom form with a select field set to allow multiple values. (There are hundreds of options so it's not possible to have checkboxes, which is what I'd prefer)

 

When you submit the form, an error should be shown if you don't have any options selected for this field but the form submits fine.

 

I'm using the following options:

 

Multiple? YesUse Empty Option? Yes
Empty Option Value: "none selected"
Empty Option Text: "- Hold CTRL to select multiple -"
Allow Empty Option To Be Selected? No
Empty Option Selected Error: "Please select at least one degree"

 

Am I doing something wrong or is there a bug.

I'm using Squiz Matrix v5.2.7.5
 


(Anthony Ponomarenko) #2

Hi there,

 

It seems you have uncovered a bug. When the option of Multiple is set to Yes, the validation is not occurring.

 

I have reported this and it should be fixed in an upcoming version. https://squizmap.squiz.net/matrix/8403 

 

However in the mean time as a workaround you could add a Rule to perform some validation on the submitted value. 

 

Add a New Rule of the type Text Contains to the question, and set that up with the value of your Empty option.


(Evan Wills) #3

Hi Anthony

 

I tried adding a validation rule (actually it was a number of validation rules) and none of them work at all. I also noticed that, once created, you cannot delete rules.

We are using Matrix 5.2.7.5

If it's useful, the asset which identified this issue is 689831:q44 (ACU Australian Catholic University)

 

My work around is to use JavaScript to validate the field.

 

PS: Every time the details screen loads for 689831:q44 loads. I get the following error. It might be related

PHP Notice
Undefined index: rule

(Anthony Ponomarenko) #4

Good news, 

 

The issue has been fixed and will be included in the next release.

 

I suggest upgrading to that version to get the fix.