Eureka: a row's isValid defaults to true, and I can't figure out how to bind a button `disabled` to the form`s is valid state
Hi,
I am trying to adopt Eureka’s new validation methods, but I’m having trouble since I want to conditionally enable and disable a button row based on if the form is valid or not. The problems are
- Each row has an initial isValid value of true (
return validationErrors.isEmpty) so if I do this my button always starts enabled despite an empty form - I can use
row.validate()but then all my validation errors start showing up despite an empty form.
Do you know of any solutions to the problem?
3 things I could imagine are:
- like in web forms having a “clean” state so I can say something like
row.isValid || row.isClean - would be really nice to have a function that evaluates the validity of a row, without side-effects (i.e without setting
self.validationErrors). - I appreciate the value of encapsulation as much as the next guy, but would it be totally crazy to have a public getter with a private setter for
rules?
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 3
- Comments: 19 (3 by maintainers)
@yoavschwartz
You can disable a button if the form validation has any errors with the below sample. For managing “Clean State”, for now you would have to wire this up manually, reacting to onChange events, and keeping a Bool flag.