I'm using a <TextInput>
in a <SimpleForm>
and when I clear out the value at runtime, react-admin sets the property's value to null
when it sends the values to the DataProvider. I would like to store empty strings instead of null. Is that possible? If so, how?
You can use react-final-form parse
prop for that (see https://final-form.org/docs/react-final-form/types/FieldProps#parse):
<TextInput
source="author.name"
parse={value => value}
/>
The default will convert empty string to undefined
(see https://final-form.org/docs/final-form/faq#why-does-final-form-set-my--field-value-to-undefined) and react-admin convert those undefined values to null.