Skip to content

Commit 8bb303e

Browse files
committed
fix(dynamic-form-group): Change return object type for nested object if it type is DynamicFormGroup
1 parent 0d26bdf commit 8bb303e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

libs/ngx-dynamic-form-builder/src/shared/utils/dynamic-form-builder.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export class DynamicFormBuilder extends FormBuilder {
88
factoryModel: ClassType<TModel>,
99
controlsConfig?: {
1010
[key: string]: any;
11-
}, extra?: {
11+
},
12+
extra?: {
1213
[key: string]: any;
1314
} | null
1415
): DynamicFormGroup<TModel> {
@@ -18,13 +19,12 @@ export class DynamicFormBuilder extends FormBuilder {
1819
}
1920
// experimental
2021
if (controlsConfig === undefined) {
21-
newControlsConfig = new factoryModel({});
22+
newControlsConfig = new factoryModel();
2223
Object.keys(newControlsConfig).forEach(key => {
2324
if (
2425
newControlsConfig[key] &&
2526
newControlsConfig[key].constructor &&
2627
typeof newControlsConfig[key] === 'object' &&
27-
newControlsConfig[key].__not_group !== true &&
2828
(
2929
newControlsConfig[key].length === undefined ||
3030
(
@@ -33,10 +33,10 @@ export class DynamicFormBuilder extends FormBuilder {
3333
)
3434
)
3535
) {
36-
newControlsConfig[key].__not_group = true;
3736
newControlsConfig[key] = this.group(
3837
newControlsConfig[key].constructor,
39-
controlsConfig !== undefined ? newControlsConfig[key] : undefined
38+
undefined,
39+
extra
4040
);
4141
}
4242
});

libs/ngx-dynamic-form-builder/src/shared/utils/dynamic-form-group.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export class DynamicFormGroup<TModel> extends FormGroup {
174174
if (object !== undefined) {
175175
Object.keys(this.controls).forEach(key => {
176176
if (this.controls[key] instanceof DynamicFormGroup) {
177-
object[key] = (this.controls[key] as DynamicFormGroup<any>).value;
177+
object[key] = (this.controls[key] as DynamicFormGroup<any>).object;
178178
} else {
179179
object[key] = this.controls[key].value;
180180
}

0 commit comments

Comments
 (0)