Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong type for formState #3884

Closed
its-dibo opened this issue Mar 22, 2024 · 1 comment
Closed

wrong type for formState #3884

its-dibo opened this issue Mar 22, 2024 · 1 comment
Labels

Comments

@its-dibo
Copy link

FormlyFormOptions.formState is defined as any, means it can accept any arbitrary value.
also, the docs says

The formState property is passed to all fields and is a mechanism for communicating between fields (without having to mess with your model).
which also means it holds arbitrary value that doesn't mean anything to firmly

but when you pass formStatus.disabled=true it disables the form, which means it has been interpreted by Formly, which is not implied neither by the type definition nor the documentation.

export interface FormlyFormOptions {
    updateInitialValue?: (model?: any) => void;
    resetModel?: (model?: any) => void;
    formState?: any;
    fieldChanges?: Subject<FormlyValueChangeEvent>;
    showError?: (field: FieldType) => boolean;
    build?: (field?: FormlyFieldConfig) => FormlyFieldConfig;
    checkExpressions?: (field: FormlyFieldConfig) => void;
    detectChanges?: (field: FormlyFieldConfig) => void;
    parentForm?: FormGroupDirective | null;
}

it should be changed to

formStats: {
  disabled: boolean 
  // other props that are used by Formly
 [key:string]: any
}
@its-dibo its-dibo added the bug label Mar 22, 2024
@aitboudad aitboudad added question and removed bug labels May 26, 2024
@aitboudad
Copy link
Member

but when you pass formStatus.disabled=true it disables the form, which means it has been interpreted by Formly, which is not implied neither by the type definition nor the documentation.

Not true, in order to disable the form you should use formStatus.disabled inside field expression.
If you think the doc should be adjusted, could you please send a PR 🙏 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants