-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReferenceInput with allowEmpty has emptyValue '', not null #3087
Comments
Hi @fvieira, There is no good value for the empty choice that works in all cases. Whether you need a number or a string, you'll want different default values. So |
Hi @fzaninotto, I totally agree with what you said, but there's still two gotchas:
|
Then it means that you're right and I'm wrong. I'm reopening this and marking it as a bug. Thanks for the report! |
Well, can't we both be right? Your arguments were on spot! ;) |
I'm having the same issue, any update? |
even with tested with react-admin 3.0.0-alpha.4 edit: sorry, #3087 (comment) already mentioned that this is not fixed. |
I debugged that a bit and it seems that its not only a matter of emptyValue. The referenceField will use I don't think that this is solved properly with |
error is still there on react-admin 3.0.1. I also noticed, that if i don't touch the field, it now sends an empty string "" to the dataprovider instead of null. When i touch the field and select the empty value there, i get a different error:
this occures notice the it will then call the sanitizeFunction with |
What you were expecting:
Using any of these:
should result in the value being
null
when the select is empty, as per the documentation:https://marmelab.com/react-admin/Inputs.html#referenceinput
What happened instead:
The value is an empty string
''
, which crashes as the dataProvider is (correctly) expecting either a integer ornull
.Environment
The text was updated successfully, but these errors were encountered: