React-admin: Can not display Fields in Create or Edit View

Created on 26 Mar 2019  路  9Comments  路  Source: marmelab/react-admin

What you were expecting:
Display Fields in Create and Edit Views.

What happened instead:
The empty div is displayed for Fields.

Steps to reproduce:
Add TextField with valide source in Edit or Create View.

In the documentation it is mentioned that it could be possible: https://github.com/marmelab/react-admin/blob/925408c86b665fa026c7798b4af10fc70127be86/docs/Fields.md

Environment

  • React-admin version: 2.7.1
  • Last version that did not exhibit the issue (if applicable):
  • React version: 16.8.1
  • Browser: Chrome
  • Stack trace (in case of a JS error):
needs more info

Most helpful comment

If you are able to illustrate the bug or feature request with an example, please provide a sample application via one of the following means:

  • CodeSandbox (https://codesandbox.io/s/349ovjmlx5)
  • A sample application via GitHub

All 9 comments

If you are able to illustrate the bug or feature request with an example, please provide a sample application via one of the following means:

  • CodeSandbox (https://codesandbox.io/s/349ovjmlx5)
  • A sample application via GitHub

@djhi @LanaIV Looks like I found a way to reproduce it stabile:
https://codesandbox.io/s/q7vvq29n3w

Consider PostsEdit view - when we put Input and Fields component (title in example) into div (or any other parent component), only Inputs are rendered.

In my case I faced with it when using MUI's Grid to customize layout.

@tusmenko I don't get it. The field is rendered in your codesandbox.

image

Oh sorry misread. @tusmenko this is another issue than the one described by @LanaIV. Indeed, the way react-admin works does not allow wrapping containers. You'll have to implement your own SimpleForm or TabbedForm for that.

@LanaIV What @tusmenko codesandbox shows however, is that you can include fields in a Edit view.

@djhi Generally It's allow, but, as you see - only Inputs, but not Edits(
Is it feature request in this case, or new bug-request to create?

Generally It's allow, but, as you see - only Inputs, but not Edits

It looks like it works but it shouldn't and is not supported. The SimpleForm and FormTab components currently inspect their children and clone them with additional props. Wrapping your inputs with any components which does not pass them those additional props down will most probably trigger bugs.

This is a known issue that we won't address any time soon. You'll have to implement your own Form component or wrappers for that. If you wish to discuss it more, please open a new issue

Sorry for delay with my response.
When I was trying with sandbox rendering of TextField & ImageField (the most important for me) was displayed, so I tried to figure out why in my code it did not work.
My fields and inputs are wrapped with other containers, so it should be because of that. When I put the fields out of containers it works.

This is a known issue that we won't address any time soon. You'll have to implement your own Form component or wrappers for that.

I'll try to implement my own component. Thanks!

There should be documentation for how to render a Field component inside of a Create/Edit component for custom layouts.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samanmohamadi picture samanmohamadi  路  3Comments

phacks picture phacks  路  3Comments

fzaninotto picture fzaninotto  路  3Comments

Kmaschta picture Kmaschta  路  3Comments

ericwb picture ericwb  路  3Comments