marmelab / react-admin

A frontend Framework for single-page applications on top of REST/GraphQL APIs, using TypeScript, React and Material Design
http://marmelab.com/react-admin
MIT License
24.89k stars 5.23k forks source link

Disabled TextInput in SimpleForm returns undefined #9929

Closed Netail closed 3 months ago

Netail commented 3 months ago

What you were expecting: Disabled TextInput value is passes initial value back

What happened instead: Disabled TextInput value is passed back as undefined

Steps to reproduce: Have a SimpleForm with a TextInput which has a disabled field for the edit page, which gets preloaded with an initial value, when saving it returns undefined

export const Edit = (): JSX.Element => {
  const { id } = useParams();
  return (
    <Edit id={id}>
      <SimpleForm warnWhenUnsavedChanges>
        <TextInput
          label="Ingredient Name"
          source="name"
          disabled
        />
      </SimpleForm>
    </Edit>
  )
}

Environment

Netail commented 3 months ago

Not sure if this is default behaviour, to set disabled input values to undefined, but something you want to use them as a display. Maybe an option for this would be nice?

fzaninotto commented 3 months ago

From https://marmelab.com/react-admin/Inputs.html#disabled:

image

Netail commented 3 months ago

Oh readOnly, sorry missed that completely. Thanks :)