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.

301 questions
28
votes
4 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
  • 3,549
  • 6
  • 25
  • 59
19
votes
6 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
  • 4,950
  • 8
  • 27
  • 48
15
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…
Rohit Jindal
  • 11,704
  • 11
  • 56
  • 92
11
votes
1 answer

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
  • 113
  • 1
  • 1
  • 5
10
votes
2 answers

Reactive Forms: How to add new FormGroup or FormArray into an existing FormGroup at a later point in time in Angular 7/8/9

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…
Lonely
  • 5,174
  • 6
  • 33
  • 67
8
votes
5 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…
7
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…
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
  • 353
  • 1
  • 7
6
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:…
Sunil Behera
  • 126
  • 1
  • 1
  • 7
5
votes
2 answers

formGroup expects a FormGroup instance : angular 4

I have created a formGroup in angular 4 where user & organization are stored in object. Now i want to populate my formgroup using these two objects. In my ts I have done the following: createForm(user: any) { this.userForm = this.fb.group({ …
Bhushan Gadekar
  • 12,317
  • 20
  • 77
  • 124
4
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
  • 403
  • 1
  • 11
  • 21
4
votes
2 answers

Angular FormArray or FormGroup - With Extra Data

I have a table that is dynamically created and it displays data as follows:
{{product.name}} {{product.description}} {{product.value}}