我正在使用 <TextInput>
在 <SimpleForm>
当我在运行时清除该值时,react-admin 将该属性的值设置为 null
当它将值发送到 DataProvider 时。我想存储空字符串而不是 null。那可能吗?如果是这样,如何?
最佳答案
您可以使用 react-final-form parse
支持(见 https://final-form.org/docs/react-final-form/types/FieldProps#parse):
<TextInput
source="author.name"
parse={value => value}
/>
默认将空字符串转换为 undefined
(参见 https://final-form.org/docs/final-form/faq#why-does-final-form-set-my--field-value-to-undefined )和 react-admin 将这些未定义的值转换为 null。
关于react-admin - 我的空 TextInput 值可以作为空字符串发送到 DataProvider 而不是转换为 null 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62853538/