fix(forms): getRawValue should correctly work with nested FormGroups/Arrays (#12964)
Closed #12963 PR Close #12964
This commit is contained in:

committed by
Miško Hevery

parent
7ac38aa357
commit
1ece7366c8
@ -32,6 +32,7 @@ export function main() {
|
||||
}
|
||||
|
||||
describe('FormArray', () => {
|
||||
|
||||
describe('adding/removing', () => {
|
||||
let a: FormArray;
|
||||
let c1: FormControl, c2: FormControl, c3: FormControl;
|
||||
@ -81,6 +82,21 @@ export function main() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('getRawValue()', () => {
|
||||
let a: FormArray;
|
||||
|
||||
it('should work with nested form groups/arrays', () => {
|
||||
a = new FormArray([
|
||||
new FormGroup({'c2': new FormControl('v2'), 'c3': new FormControl('v3')}),
|
||||
new FormArray([new FormControl('v4'), new FormControl('v5')])
|
||||
]);
|
||||
a.at(0).get('c3').disable();
|
||||
(a.at(1) as FormArray).at(1).disable();
|
||||
|
||||
expect(a.getRawValue()).toEqual([{'c2': 'v2', 'c3': 'v3'}, ['v4', 'v5']]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('setValue', () => {
|
||||
let c: FormControl, c2: FormControl, a: FormArray;
|
||||
|
||||
|
Reference in New Issue
Block a user