question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose form validity

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
zakhenrycommented, Jun 24, 2019

@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

abstract class MyRootFormComponent<T> extends NgxRootFormComponent<T> {
  // implement utility getters here
}
1reaction
AlexAegiscommented, Jun 19, 2019

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.

	public ngOnInit(): void {
		super.ngOnInit();
	}

I dug a little deeper and I see you use the OnDestroy hook too. Mention that too please.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found