Ticket #339 (closed defect: fixed)
setWireValue(...,true) sets fields valid instead of unvalidated
| Reported by: | sdm | Owned by: | freya |
|---|---|---|---|
| Priority: | major | Milestone: | 0.4 |
| Component: | modules/kauri-forms | Version: | trunk |
| Keywords: | Cc: | kauri-discuss@… |
Description
A call to setWireValue() with the second parameter (noValidation) set to true, sets fields valid (or in case an invalid value was passed in the setWireValue: invalid), even though the second parameter says not to validate yet, and the fields should remain unvalidated.
For example: if your form config has a field "name" with a required validator, and you initialise the form, the "name" field doesn't have the 'valid' nor the 'invalid' class (=normal behaviour). If you then call setWireValue({},true), the "name" field will have the 'valid' class, but when you try to submit the form, the field gets the 'invalid' class.
Change History
comment:2 Changed 3 years ago by freya
OK it's about the valid/invalid class that shouldn't even be there when there was no validation, of course.
solved in r1567. can you check your case, stephanie?
comment:3 Changed 3 years ago by sdm
Now it's working almost completely: setWireValue doesn't add 'valid' or 'invalid' class attributes anymore when noValidation=true, so this is good.
But I've noticed that the case-control still has the valid class after initialisation of the form. You can also see this in the forms-sample, page advanced-controls: the selection-list of the case-control where you can choose between "phone" and "email", has the 'valid' class after initialisation of the form.
comment:5 Changed 3 years ago by sdm
- Status changed from closed to reopened
- Resolution fixed deleted
The case-control still has the valid class after initialisation of the form.
comment:6 Changed 3 years ago by freya
- Owner changed from mpo to freya
- Status changed from reopened to assigned
Hello,
I'm not sure if I understand the problem.
Example: basic-form1 in the samples.
'name': { base: 'string', '+validators': { 'required': {} }, label: "name" }, 'email': { base: 'string', '+validators': { 'isEmail': {} }, label: "e-mail" } basicForm.setWireValue({ "email":"geenvalidemail" }, true);Then there is no validation done in setWireValue, and the class set to the input fields is "valid". When submitting the form, validation is done en class is set to 'invalid'.
When done
basicForm.setWireValue({ "email":"geenvalidemail" }, false);everything is immediately validated and the classes are set to invalid.