Skip to content

Commit

Permalink
apply suggestion and v1 pr inputs tip modif
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanMarmelab committed Feb 27, 2024
1 parent d7fb85f commit 98ba645
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
10 changes: 4 additions & 6 deletions docs/Inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,25 +153,23 @@ export const PostCreate = () => (

## `readOnly`

If `true`, the input is in read-only mode and the user can't change the value.
The `readOnly` prop set to true makes the element not mutable, meaning the user can not edit the control.

```tsx
<TextInput source="title" readOnly />
```

## `disabled`

If `true`, the input is disabled and the user can't change the value.
The `disabled` prop set to true makes the element not mutable, focusable, or even submitted with the form.

```tsx
<TextInput source="title" disabled />
```

**Tip:** Note that `disabled` inputs are **not** included in the form values, and hence may trigger `warnWhenUnsavedChanges` if the input previously had a value in the record. To include the input in the form values, you can use `readOnly` instead of `disabled`. The workaround is to set the `disabled` prop on the underlying input component, as follows:
**Warning:** Note that `disabled` inputs are **not** included in the form values, and hence may trigger `warnWhenUnsavedChanges` if the input previously had a value in the record.

```jsx
<TextInput source="title" InputProps={{ disabled: true }} />
```
**Tip:** To include the input in the form values, you can use `readOnly` instead of `disabled`.

## `format`

Expand Down
1 change: 0 additions & 1 deletion packages/ra-ui-materialui/src/input/BooleanInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ BooleanInput.propTypes = {
// @ts-ignore
options: PropTypes.shape(Switch.propTypes),
disabled: PropTypes.bool,
readOnly: PropTypes.bool,
};

export type BooleanInputProps = Omit<CommonInputProps, 'readOnly'> &
Expand Down

0 comments on commit 98ba645

Please sign in to comment.