diff --git a/src/components/FormBuilder/fields/InputField.tsx b/src/components/FormBuilder/fields/InputField.tsx index daa3159..4add6ac 100644 --- a/src/components/FormBuilder/fields/InputField.tsx +++ b/src/components/FormBuilder/fields/InputField.tsx @@ -34,6 +34,11 @@ export const InputField = withConditional( e.stopPropagation(); }; + const disabled = + typeof field.disabled === "function" + ? field.disabled(form.getValues()) + : field.disabled; + return ( ( field.mode === "number" && diff --git a/src/components/FormBuilder/fields/selects/SelectField.tsx b/src/components/FormBuilder/fields/selects/SelectField.tsx index 677a87b..8b2f2fb 100644 --- a/src/components/FormBuilder/fields/selects/SelectField.tsx +++ b/src/components/FormBuilder/fields/selects/SelectField.tsx @@ -20,40 +20,48 @@ export interface SelectFieldProps extends BaseField { } export const SelectField = withConditional( - ({ form, field }) => ( - ( - - {field.label} - {field.description} - - - - - - - - {field.options.map((option) => ( - - {option.label} - - ))} - - + ({ form, field }) => { + const disabled = + typeof field.disabled === "function" + ? field.disabled(form.getValues()) + : field.disabled; - - - )} - /> - ) + return ( + ( + + {field.label} + {field.description} + + + + + + + + {field.options.map((option) => ( + + {option.label} + + ))} + + + + + + )} + /> + ); + } );