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

Cannot use TextField inside of an iterator within a form #6393

Closed
andrico1234 opened this issue Jun 25, 2021 · 3 comments
Closed

Cannot use TextField inside of an iterator within a form #6393

andrico1234 opened this issue Jun 25, 2021 · 3 comments

Comments

@andrico1234
Copy link
Contributor

What you were expecting:
If I wanted to display some static data from a record from within an Edit page, I should expect to use a TextField as normal to output the data.

What happened instead:
Code like this:

const PostEdit = props => {
    return (
        <Edit title={<PostTitle />} {...props}>
            <TabbedForm>
                <FormTab label="post.form.summary">
                    <ArrayInput source="backlinks">
                        <SimpleFormIterator>
                            <TextField source="url" />
                            <TextInput source="url" />
                        </SimpleFormIterator>
                    </ArrayInput>
                </FormTab>
            </TabbedForm>
        </Edit>
    );
};

Displays the following:
image

Steps to reproduce:
You can find the repro case here
Run the simple-demo and access post 12

Related code:
It looks like a problem with the TextField component itself.

The value returned from useRecordContext is

{ url: "https://blog.johndoe.com/2012/08/12/foobar.html }

Where the source passed through is: backlinks[1].url.

  • React-admin version: 3.16.2
  • Last version that did not exhibit the issue (if applicable):
  • React version:
  • Browser:
  • Stack trace (in case of a JS error):
@andrico1234 andrico1234 changed the title Cannot use TextField inside of an iterator within an a form Cannot use TextField inside of an iterator within a form Jun 25, 2021
@djhi
Copy link
Collaborator

djhi commented Jun 28, 2021

Yes, the SimpleFormIterator should provide a RecordContext. Thanks for reporting

@djhi djhi added the bug label Jun 28, 2021
@WiXSL
Copy link
Contributor

WiXSL commented Dec 7, 2021

@andrico1234,
Unless I'm misunderstanding, this is cover in the documentation
You have to use a FormDataConsumer inside an SimpleFormIterator in order to use a TextField

This is not a bug

@andrico1234
Copy link
Contributor Author

You're right!

@WiXSL WiXSL removed the bug label Dec 15, 2021
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