Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(forms): throw error if wrong control container for reactive forms #10286

Merged
merged 1 commit into from Jul 26, 2016

Conversation

kara
Copy link
Contributor

@kara kara commented Jul 26, 2016

This PR ensures that there are clearer error messages for incorrect or missing reactive form containers.

Before
Case 1: Missing parent formGroup

<input formControlName="name">

Error: No provider for ControlContainer

Case 2: Trying to use a regular form tag without a formGroup

<form>
   <input formControlName="name">
</form>

Error: Cannot setParent of null

After

Now in these cases, the error will be a bit more descriptive:

Error: formControlName must be used with a parent formGroup directive. 
You'll want to add a formGroup directive and pass it an existing FormGroup instance 
(you can create one in your class).

Example:

<div [formGroup]="myGroup">
   <input formControlName="firstName">
</div>

In your class: 

this.myGroup = new FormGroup({
   firstName: new FormControl()
});

@kara kara added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jul 26, 2016
@kara
Copy link
Contributor Author

kara commented Jul 26, 2016

Got verbal LGTM from Victor

@kara kara added pr_state: LGTM and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 26, 2016
@kara kara merged commit 0aba42a into angular:master Jul 26, 2016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants