IssueRaiser

feat(Forms) Expose FormControl errors to parent FormGroup

**I'm submitting a ...** (check one with "x") ``` [ ] bug report [x feature request [ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question ``` **Current behavior** When there are errors in a form group, the formGroup.status is 'INVALID' but the formGroup.errors property is null. ex. ``` formGroup.controls.username.errors: {invalidEmail: true} formGroup.errors: null ``` **Expected/desired behavior** When the validity of a FormControl changes, have the parent FormGroup.errors merged with the errors from the controls. This is similar to how the angularjs formController.$error property works. https://docs.angularjs.org/api/ng/type/form.FormController **What is the motivation / use case for changing the behavior?** This would be helpful because I prefer to only disable a submit button when specific errors are on a form, such as required. With this I could drive that attribute off the formControl.errors value instead of formControl.status. ex. ``` From: <button [disabled]="myForm.status !== 'VALID'">Submit</button> To: <button [disabled]="myForm.errors.required">Submit</button> ```

Posted by mhamel06 on Aug 5, 2016, 3:41 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.5,000 issues0 comments

support (Software)

feat(Forms) Expose FormControl errors to parent FormGroup

mhamel06Aug 5, 2016, 3:41 PM

**I'm submitting a ...** (check one with "x") ``` [ ] bug report [x feature request [ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question ``` **Current behavior** When there are errors in a form group, the formGroup.status is 'INVALID' but the formGroup.errors property is null. ex. ``` formGroup.controls.username.errors: {invalidEmail: true} formGroup.errors: null ``` **Expected/desired behavior** When the validity of a FormControl changes, have the parent FormGroup.errors merged with the errors from the controls. This is similar to how the angularjs formController.$error property works. https://docs.angularjs.org/api/ng/type/form.FormController **What is the motivation / use case for changing the behavior?** This would be helpful because I prefer to only disable a submit button when specific errors are on a form, such as required. With this I could drive that attribute off the formControl.errors value instead of formControl.status. ex. ``` From: <button [disabled]="myForm.status !== 'VALID'">Submit</button> To: <button [disabled]="myForm.errors.required">Submit</button> ```

Comments (0)

No comments yet. Start the discussion.

Comment on this issue