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

Add ability to accept more than one child in <Reference> Fields #7812

Merged
merged 16 commits into from
Jun 16, 2022

Conversation

fzaninotto
Copy link
Member

@fzaninotto fzaninotto commented Jun 10, 2022

Problem

Developers often need to render more than one field of the reference table (e.g. if the users table has a first_name and a last_name field) in a <ReferenceField>. And <FunctionField> is a bit cumbersome.

Solution

Let <ReferenceField> accept more than one child, so that developers can use as many <Field> as they like:

import { Show, SimpleShowLayout, ReferenceField, TextField, DateField, FunctionField } from 'react-admin';

export const PostShow = () => (
    <Show>
        <SimpleShowLayout>
            <TextField source="id" />
            <TextField source="title" />
            <DateField source="published_at" />
            <ReferenceField label="Author" source="user_id" reference="users">
                <TextField source="first_name" />{' '}
                <TextField source="last_name" />
            </ReferenceField>
        </SimpleShowLayout>
    </Show>
);
  • <ReferenceField> code, doc and tests
  • <ReferenceManyField> code, doc and tests
  • <ReferenceOneField> code, doc and tests
  • <ReferenceArrayField> code, doc and tests

@fzaninotto fzaninotto added the RFR Ready For Review label Jun 10, 2022
@fzaninotto fzaninotto added this to the 4.2.0 milestone Jun 10, 2022
Copy link
Contributor

@slax57 slax57 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, that's great! And we can probably do the same with ReferenceManyField too

docs/ReferenceField.md Outdated Show resolved Hide resolved
Co-authored-by: Jean-Baptiste Kaiser <[email protected]>
docs/ReferenceField.md Outdated Show resolved Hide resolved
docs/ReferenceField.md Show resolved Hide resolved
docs/ReferenceField.md Outdated Show resolved Hide resolved
fzaninotto and others added 2 commits June 13, 2022 14:05
Co-authored-by: Gildas Garcia <[email protected]>
Co-authored-by: Gildas Garcia <[email protected]>
Copy link
Contributor

@slax57 slax57 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build is failing though 🙁

@fzaninotto
Copy link
Member Author

It was a GitHub failure. I relaunched the build and it passes.

@vercel vercel bot temporarily deployed to Preview – react-admin June 13, 2022 17:25 Inactive
@fzaninotto fzaninotto added WIP Work In Progress and removed RFR Ready For Review labels Jun 13, 2022
@fzaninotto
Copy link
Member Author

Back to WIP to address other reference field components

@fzaninotto fzaninotto added RFR Ready For Review and removed WIP Work In Progress labels Jun 15, 2022
@fzaninotto
Copy link
Member Author

back to RFR

@vercel vercel bot temporarily deployed to Preview – react-admin June 15, 2022 10:44 Inactive
@fzaninotto fzaninotto changed the title Add ability to accept more than one child in <ReferenceField> Add ability to accept more than one child in <Reference> Fields Jun 15, 2022
@vercel vercel bot temporarily deployed to Preview – react-admin June 15, 2022 14:26 Inactive
Copy link
Collaborator

@djhi djhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

docs/ReferenceArrayField.md Outdated Show resolved Hide resolved
docs/ReferenceArrayField.md Outdated Show resolved Hide resolved
@slax57 slax57 merged commit 8921416 into next Jun 16, 2022
@slax57 slax57 deleted the reference-children branch June 16, 2022 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants