Giter VIP home page Giter VIP logo

Comments (5)

fzaninotto avatar fzaninotto commented on March 29, 2024

In fact, you can (almost) do it already. Just use <Field> components inside the <Edit> view. It'll work, but you'll still have a save button.

We need to make it possible, so I'm tagging that as feature request.

from react-admin.

pimschaaf avatar pimschaaf commented on March 29, 2024

I've been trying to use the <Show> view as per example but run into warnings when I include more than one <TextField> in the <Show> component:

Warning: Failed prop type: Invalid prop children of type array supplied to Show, expected a single ReactElement.

App.js

    import React from 'react';
    import { jsonServerRestClient, Admin, Resource } from 'admin-on-rest';
    import { Delete } from 'admin-on-rest/lib/mui';
    import { TaxationList, TaxationCreate, TaxationShow, TaxationEdit } from './views/Taxations';

    const App = () => (
    <Admin dashboard={Dashboard} menu={Menu} messages={messages} restClient={jsonServerRestClient('http://localhost:3004')}>
        <Resource name="taxations" list={TaxationList} create={TaxationCreate} edit={TaxationEdit} show={TaxationShow} remove={Delete}/>
    </Admin>
    );

    export default App;

Taxations.js

export const TaxationShow = (props) => (
  <Show {...props}>
      <TextField source="id" />
      <TextField source="details" />
  </Show>
);

When I only include a singular <TextField source="id" /> in <Show> the ID is shown, but the field styling is not as I would expect.

Image of Show with ID Textfield only

I'm new to admin-on-rest, so I might be making a rookie mistake. Let me know if I can provide more relevant information.

Thanks

from react-admin.

fzaninotto avatar fzaninotto commented on March 29, 2024

You didn't look at the example carefully enough: <Show> expects only one child, which is a layout component.

from react-admin.

pimschaaf avatar pimschaaf commented on March 29, 2024

@fzaninotto Thanks! Indeed I missed that. I stumbled on the <Show> component through the Reference, working from the assumption that <Show> would work like <Edit>, then missed the details in the commit referenced here.

I suppose the Reference could use a PR with more details about the implementation of <Show>?

from react-admin.

fzaninotto avatar fzaninotto commented on March 29, 2024

Great idea!

from react-admin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.