-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Update FormBuilder#control()
to support AbstractControlOptions
as 2nd parameter
#19163
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
Comments
I also have this issue.
Here the FormBuilder just ignores passed options. |
What's the recommended workaround? Not to use FormBuilder if you need these? |
I've also noted that in the Form Builder - Group docs it mentions
But in the FormControl docs it show that you can add the updateOn. I assume this was missed when updateOn was added. |
WORKAROUND
What should work though, but doesn't currently:
|
I had no luck with the workaround. I will wait for this to be resolved before using updateOn. |
+1 for this feature. It's very inconvenient that we need to use FormControl constructors instead of FormBuilder to set validation onBlur. |
+1 for this for consistency and ease of use. |
+1 for this for consistency and ease of use as well. For others looking for a work around until this is resolved, the code below works for us:
|
Same here |
|
Is it the same issue if I want to have 2 validators like this:
|
Would love to see this feature |
Thank you, @dthomas722! Just to clear up your snippet let myFormGroup = this.formBuilder.group({
control1: 'control 1 value',
control2: 'control 2 value',
});
myFormGroup = new FormGroup(myFormGroup.controls, { updateOn: 'blur' }); or const myFormGroup = new FormGroup(this.formBuilder.group({
control1: 'control 1 value',
control2: 'control 2 value',
}).controls, { updateOn: 'blur' }); |
will be great!! |
@kara just to add more information to the bug, the solution as suggested by @LayZeeDK & @dthomas722 works when we use a default html control like input but the solution does not work when we have a custom form control being used. example below:
For some one looking for a workaround (Please correct me if my usage is incorrect for custom form control) The work around is to not to have the [formControlName] on the template where custom control is called as shown above, but to have it inside the template of myTextEditComponent. Although this does not look nice because now i have to pass in the value by exposing another @input property which takes the value for the control. for example template for myTextEditComponent
And the first code snippet changing to
UPDATE while calling <my-text-edit>
Template of myTextEditComponent
Thanks, |
what's the status on this? |
It is coming! 🙌 (version 7.1.0 at the earliest)
|
PR #24599 code has been merged. |
@pkaushik23: @kara delivered the best talk on Angular Forms at AngularConnect 2017 where she shows how to avoid the anti-pattern of passing form groups down the component tree by injecting |
You can now try out this feature in |
@LayZeeDK Thanks for your help getting this fixed! Closing as done. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a...
Current behavior
In 5.x version
AbstractControlOptions
has been added as parameter toFormControl
constructor.FormBuilder#control()
method should create new control by provided configuration. Currently signature/input parameters do not matchFormControl
.Expected behavior
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Just to keep code consistent
Environment
Angular version: 5.0.0-beta6
Other
It would be nice, if you could also update
FormBuilder#group()
to supportAbstractControlOptions
when simple json is provided.The text was updated successfully, but these errors were encountered: