ReferenceOneField emptyContent instead of emptyText
Is your feature request related to a problem? Please describe. In a many to many scenario where I have partner => channelPartner => paymentChannel tables.
channelPartner table stores additional information about the related records like commission rates.
I'm listing all the paymentChannels in the edit page of partner. In case there's no record in channelPartner which links these 2 records I want it to navigate to the create page of channelPartner with the foreignKeys are prefilled.
Describe the solution you'd like
ReferenceOneField links to edit page of the referenced resource by default which is great. But if there's no referenced record I want to create a record. If I could add a link to create page on empty records that'd be simple to implement this feature. Something like this:
function(){
return(
<Edit resource={'partner'}>
<SimpleForm>
<TextInput source="name"/>
<ListBase resource={"paymentChannel"}>
<Datagrid >
<TextField source="name"/>
{/*If there's no record in the junction table (channelPartner), I want to link to create page */}
<ReferenceOneField reference={"channelPartner"} target={"paymentChannelId"} label={'Deposit Commision'}
//This would be great
emptyContent={<Button to={'channelPartner/create'}/>}
/>
</Datagrid>
</ListBase>
</SimpleForm>
</Edit>
)
}
Describe alternatives you've considered I'm still exploring. Not found a solution yet.
Great idea! Can you open a pull request? This should target the next branch
Actually it's only a type issue. I could still pass a component to emptyText.
So probably just the naming and type should be changed.
I really like this library, so I'd like to contribute. I'll try sparing some time and create a pull request.