Skip to content

Commit

Permalink
fix(dynamic-form-group): Change return object type for nested object …
Browse files Browse the repository at this point in the history
…if it type is DynamicFormGroup
  • Loading branch information
EndyKaufman committed Mar 1, 2018
1 parent 0d26bdf commit 8bb303e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export class DynamicFormBuilder extends FormBuilder {
factoryModel: ClassType<TModel>,
controlsConfig?: {
[key: string]: any;
}, extra?: {
},
extra?: {
[key: string]: any;
} | null
): DynamicFormGroup<TModel> {
Expand All @@ -18,13 +19,12 @@ export class DynamicFormBuilder extends FormBuilder {
}
// experimental
if (controlsConfig === undefined) {
newControlsConfig = new factoryModel({});
newControlsConfig = new factoryModel();
Object.keys(newControlsConfig).forEach(key => {
if (
newControlsConfig[key] &&
newControlsConfig[key].constructor &&
typeof newControlsConfig[key] === 'object' &&
newControlsConfig[key].__not_group !== true &&
(
newControlsConfig[key].length === undefined ||
(
Expand All @@ -33,10 +33,10 @@ export class DynamicFormBuilder extends FormBuilder {
)
)
) {
newControlsConfig[key].__not_group = true;
newControlsConfig[key] = this.group(
newControlsConfig[key].constructor,
controlsConfig !== undefined ? newControlsConfig[key] : undefined
undefined,
extra
);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class DynamicFormGroup<TModel> extends FormGroup {
if (object !== undefined) {
Object.keys(this.controls).forEach(key => {
if (this.controls[key] instanceof DynamicFormGroup) {
object[key] = (this.controls[key] as DynamicFormGroup<any>).value;
object[key] = (this.controls[key] as DynamicFormGroup<any>).object;
} else {
object[key] = this.controls[key].value;
}
Expand Down

0 comments on commit 8bb303e

Please sign in to comment.