Questions tagged [formgroups]

Questions about Angular FormGroup, a built-in building block used to define forms. It tracks & controls the value and validity of a group of FormControls. Available in @angular/forms package.

Angular FormGroup is a building block in @angular/forms package, used to define forms. Other building blocks are FormControl and .

It tracks & controls the value and validity of a group of FormControls and combines values of each FormControl into one object.

Related tags: , ,

See the official guide for a detailed introduction to FormGroup.

463 questions
59
votes
5 answers

Angular form builder vs form control and form group

Is there any advantage of using form control and form group over form builder? I have seen here that: The FormBuilder provides syntactic sugar that shortens creating instances of a FormControl, FormGroup, or FormArray. It reduces the amount of…
YulePale
  • 6,688
  • 16
  • 46
  • 95
33
votes
7 answers

How to disable all FormControls inside a FormGroup

I have this reactive Angular Form structure: myForm: FormGroup; Personal: FormGroup; FIRST_NAME: FormControl; LAST_NAME: FormControl; ngOnInit(): void { this.createFormControls(); this.createForm(); } createFormControls() { …
Ankit Raonka
  • 6,429
  • 10
  • 35
  • 54
18
votes
7 answers

Angular 6, this.formGroup.updateValueAndValidity() not working properly

I am trying to add and remove validators in a formGroup controls based on certain condition. When I am updating the validators through formGroup.updateValueAndValidity() for whole form its not updating, where as if I am specifically applying for…
15
votes
2 answers

Reactive Forms: How to add new FormGroup or FormArray into an existing FormGroup at a later point in time in Angular till v14

In the other examples at StackOverflow there are many questions about using FormGroups in FormArrays. But my question is the opposite. FormArrays have a push method, that makes many things possible. FormGroups have indeed an addControl method for…
user3025289
14
votes
4 answers

Kendo : Insert a FormGroup at a top into a FormArray

Problem Statement : In below stackblitz demo, I am able to insert the FormGroup dynamically at the starting of the grid on clicking the Add button and triggering the (blur) event from one control to update the value of another control sharing same…
Debug Diva
  • 26,058
  • 13
  • 70
  • 123
14
votes
2 answers

Angular FormArray: Cannot find control with path

I trying to build an Angular Reactive form where an account can add many students. The form seems to work. When you hit Add Student it creates a new student but you check the console it says ERROR Error: Cannot find control with path:…
Ty Tran
  • 143
  • 1
  • 1
  • 5
13
votes
2 answers

How to get value as type Number on this.formgroup.value()?

The value I get on submitting a form group is { "name": "Sunil", "age": "23" } What I want is { "name": "Sunil", "age": 23 } My form group is as follows in my .ts file myForm : FormGroup; this.myForm = this._formbuilder.group({ name:…
last_seen_404
  • 192
  • 1
  • 2
  • 9
10
votes
2 answers

Angular forms: best practise for complex nested reactive forms and validation at root component

I've been struggling for a few days to find a good pattern for my use case. I have a very complex reactive form, full of nested components, some fields are required, some fields may appear given certain conditions, etc... and this is creating a huge…
user3353167
  • 782
  • 2
  • 16
  • 31
10
votes
3 answers

Getting Error: formGroup expects a FormGroup instance. Please pass one in

I am new to Angular 2 and unable to resolve this issue even after going through other stack overflow answers. I have just now started learning angular reactive forms and want to try the first example but am stuck. Please help. Here is the HTML…
7
votes
1 answer

Angular Reactive Form with dynamic fields

I'm currently battling with Angular form array. I have a form in which I add the fields dynamically. I have created the form object: this.otherDataForm = this.fb.group({ }); I add the dynamic fields like this: addField(field: CustomFormField): void…
jenesuispastom
  • 129
  • 1
  • 1
  • 7
7
votes
3 answers

Angular7: NullInjectorError: No provider for FormGroup

I'm getting really fustrated because I have no idea what's happening. Everything worked correctly this morning right before some changes I made to merge together 2 forms in a ReactiveForm and now I get the following error in the browser: Error:…
Martin Carre
  • 1,157
  • 4
  • 20
  • 42
6
votes
2 answers

Reactive Forms submitted state

I was wondering if there was any way to retrieve the 'submitted' state of a Reactive Form. With template driven forms you can access the FormGroupDirective via the 'ngForm' as follows
6
votes
0 answers

Resetting FormGroup with value arg properly resets FormGroup, but clears HTML inputs associated with FormControls

I have a form using angular 7. I'm having an issue with my FormGroup, and HTML inputs associated with that FormGroup's FormControls falling out of sync after resetting. My inputs are cleared, but my form controls have the expected reset values. I…
wilbur
  • 393
  • 1
  • 9
5
votes
0 answers

Difference between UntypedFormControl and FormControl #Angular14 #AngularMigration

I recently migrated from Angular12 to Angular14, Angular automatically converted FormControl to UntypedFormControl in some places. I observed that in some components where I am using FormControl it is still written as FormControl. So I am bit…
5
votes
2 answers

angular validation state of a nested ControlValueAccessor is not correctly propagated in parents, how to implement this validation?

I have an issue in an angular 10 app, with the propagation of the state of a formGroup to its parent, at initialization. Issue: at component initialization, the validation state of a sub-form is not correctly propagated in parents of more than one…
1
2 3
30 31