EmptyText on a ReferenceField in react-admin not working?

Viewed 109

I've been trying to make work the emptyText prop on a ReferenceField nested in an ArrayField in react-admin but so far to no avail. To provide more detail, the ArrayField represents a collection of notification records associated with the resource (a report of some sort) in a one-to-many kind of relationship (i.e. one report may have many notifications associated with it).

These subordinate records themselves contain a few foreign keys to other resources (one of them being contact persons who are the recipients of those notifications). However, the user that is logged in may not have the necessary privileges to see details of those other contact persons and so when react-admin queries the API server for details on the contact persons in order to fill in their names into the appropriate cell in the Datagrid within the ArrayField, the response may arrive with fewer records than expected because of that. When that happens, I would like to use the emptyText prop on the ReferenceField that is supposed to represent the name of the contact person to instead have some placeholder text, but the field in the table that gets rendered is empty (i.e. has no children).

Basically, this is a snippet of the code I use to implement the ArrayField and its children:

    <ArrayField source="notifications" fieldKey="id" key="id">
        <Datagrid>
            <ReferenceField
                label={translate("resources.contactpersons.single")}
                source="contactPersonId"
                reference="contactpersons"
                link={permissions === roles.SystemAdminRoleID ? "edit" : false}
                emptyText="test text"
            >
               <FunctionField
                   source="lastName"
                   render={ContactPersonFullNameReversed}
               />
            </ReferenceField>
...

The test text will be replaced by a call to translate but at the moment, I cannot even get it to show up.

I suppose I am doing something wrong but the documentation seems pretty clear to me. I have noticed that ArrayField does not support the emptyText prop, but I assume, since I am not setting it on that component but instead on a ReferenceField, that it should not matter.

Thanks in advance for any insight.

0 Answers
Related