Expose form validity
See original GitHub issueI have a button to save the form outside the form component, I want to enable it only when the form is valid. This is easy if you have a reference to the formgroup: [disabled]="!form.valid"
If you’d expose this property of the form with a getter I can get this functionality back.
public get valid(): boolean {
return this.formGroup.valid;
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Exposed form validation [#3295398] | Drupal.org
Find a way to validate the exposed form with a non-breaking error message if the values are not input as required. Comments. Comment ......
Read more >Custom validate exposed filter on a view - Drupal Answers
Another approach is to use hook_form_FORM_ID_alter() like other answers suggest, but to put custom validation before the default validation ...
Read more >Why Form Validation is Critical to Securing Your Web Forms
Improper validation of form data is one of the main causes of security vulnerabilities. It exposes your website to attacks such as header...
Read more >How can I check transcluded form's validity in directive?
To answer your primary question, you can expose and bind the form like any other model value:.
Read more >Better native form validation | oliverjam.es
This API provides access to and control of all the native validation features, but via JavaScript. Validity state. The browser exposes the " ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@maxime1992 yes I think this is an unusual enough case (save from outside the root form) to not warrant adding a bunch of extra boilerplate to the library as this could easily be implemented by users by creating their own
Also, I found a bigger issue. But this can be solved by just updating your readme. You’re using the ngOnInit hook in the parent class. If I too want to use it then that will overwrite yours. In this case I have to call
super.ngOnInit()
explicitly to make it work. Please emphasize this in the README.I dug a little deeper and I see you use the
OnDestroy
hook too. Mention that too please.