React-admin: ReferenceField doesn't allow undefined values

Created on 1 May 2017  路  4Comments  路  Source: marmelab/react-admin

Use case:
I have an optional reference field on my entity whose value is either undefined or an id of another entity

Expected:
admin-on-rest checks the value of the record with the given source prop, and if undefined displays nothing, otherwise a request for the referenced entity is sent and the reference child field is displayed

Actual:
admin-on-rest sends a GET_MANY request with parameter ids as ["undefined"]

bug

Most helpful comment

Did you set the allowEmpty prop on <ReferenceField>?

All 4 comments

Did you set the allowEmpty prop on <ReferenceField>?

Yes I have. It didn't make a difference, and I can tell by code inspection no checks are made for undefined values and no tests are written for that case

Confirmed, that's a bug

@fzaninotto can we do the same thing with ReferenceArrayField ? I can send a pr if you are okay with this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rkyrychuk picture rkyrychuk  路  3Comments

phacks picture phacks  路  3Comments

kikill95 picture kikill95  路  3Comments

9747749366 picture 9747749366  路  3Comments

fzaninotto picture fzaninotto  路  3Comments