-
-
Notifications
You must be signed in to change notification settings - Fork 411
Description
Summary
Currently, the renderFormField function in Toolpad Core’s DataSource fields does not provide access to the values of other fields in the form. This makes it impossible to implement dynamic forms where the visibility or behavior of a field depends on the value of another field.
Examples
For example, I want to display the length field
only when the type field is string
. With the current signature:
renderFormField: ({ value, onChange, error }) => React.ReactNode
it is not possible to access the value of type to conditionally render the length field.
Suggested new signature:
renderFormField: ({ value, onChange, error, formState }) => React.ReactNode
This would allow code like:
renderFormField: ({ value, onChange, error, formState }) => {
if (formState.type !== 'string') return null;
return <TextField ... />;
}
Motivation
Allowing access to the form state inside renderFormField would enable the creation of more dynamic and responsive forms, improving user experience and making Toolpad Core more flexible for advanced use cases.
Search keywords: crud renderFormField formState dataSource