You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From my understanding, this is how an optional text-field would be handled in a backend
not present in the object => optional => don't touch it
empty string "" => set the value as an empty string
any other string => set the value.
So it might make sense to remove the value from the object when the state has not changed, but to make it null when it is empty feels a bit counter-intuitive to me. In pydantic for example this would be an error:
This seems to be a choice made by react-admin dev's and that*s okay, but I would like to get your motivation on this and maybe you can point me to the backends that implemented this in that particular way?
I will also send a pull-request to update the docs with an example if that's okay.
What you were expecting:
I have a couple of forms with textfields.
An example openapi spec would be:
Here is what i would expect:
create:
update
What happened instead:
When "nickname" was empty, in the request object "nickname" was set to null.
this is documented behavior:
https://github.com/marmelab/react-admin/blob/master/docs/SimpleForm.md#sanitizeemptyvalues
and it is stated that this is expected by most backends.
react-admin/packages/ra-core/src/form/useInput.ts
Lines 23 to 24 in 032e146
From my understanding, this is how an optional text-field would be handled in a backend
So it might make sense to remove the value from the object when the state has not changed, but to make it null when it is empty feels a bit counter-intuitive to me. In pydantic for example this would be an error:
Also this reads to me as it would be preferable to use an empty string:
https://stackoverflow.com/questions/45575493/what-does-required-in-openapi-really-mean
This seems to be a choice made by react-admin dev's and that*s okay, but I would like to get your motivation on this and maybe you can point me to the backends that implemented this in that particular way?
I will also send a pull-request to update the docs with an example if that's okay.
related issues/prs
#8188
#8262
#8472
Environment
The text was updated successfully, but these errors were encountered: