Skip to content
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

ReferenceOneField emptyContent instead of emptyText #10185

Open
devcloud777 opened this issue Sep 6, 2024 · 2 comments
Open

ReferenceOneField emptyContent instead of emptyText #10185

devcloud777 opened this issue Sep 6, 2024 · 2 comments

Comments

@devcloud777
Copy link

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.

@djhi
Copy link
Collaborator

djhi commented Sep 6, 2024

Great idea! Can you open a pull request? This should target the next branch

@devcloud777
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants