Skip to content

Commit

Permalink
fix: formControlNames are now generated from formControls instead of …
Browse files Browse the repository at this point in the history
…formGroup.value to correctly include disabled controls

Fixes #303
  • Loading branch information
JoschuaSchneider authored and maxime1992 committed Oct 25, 2023
1 parent 43dede0 commit b579428
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion projects/ngx-sub-form/src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from './ngx-sub-form.types';
import {
ArrayPropertyKey,
Controls,
ControlsNames,
NewFormErrors,
OneOfControlsTypes,
Expand Down Expand Up @@ -122,7 +123,9 @@ export function createFormDataFromOptions<ControlInterface, FormInterface extend
options.formGroupOptions as AbstractControlOptions,
) as TypedFormGroup<FormInterface>;
const defaultValues: FormInterface = cloneDeep(formGroup.value);
const formGroupKeys: (keyof FormInterface)[] = Object.keys(defaultValues) as (keyof FormInterface)[];
const formGroupKeys: (keyof Controls<FormInterface>)[] = Object.keys(
options.formControls,
) as (keyof Controls<FormInterface>)[];
const formControlNames: ControlsNames<FormInterface> = formGroupKeys.reduce<ControlsNames<FormInterface>>(
(acc, curr) => {
acc[curr] = curr;
Expand Down

0 comments on commit b579428

Please sign in to comment.