Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion docs/SimpleForm.md
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ const authProvider = {

const ProductEdit = () => (
<Edit>
<SimpleForm>
<SimpleForm showReadOnly>
<TextInput source="reference" />
<TextInput source="width" />
<TextInput source="height" />
Expand All @@ -890,3 +890,28 @@ const ProductEdit = () => (
</Edit>
);
```

Read-only inputs are still included in the data submitted by the form. If you don't want to send these fields to the `dataProvider`, use the `showDisabled` prop instead. Inputs for which users have only `read` access will be displayed but disabled, and omitted from the submitted data:

```tsx
import { Edit, TextInput } from 'react-admin';
import { SimpleForm } from '@react-admin/ra-rbac';

const ProductEdit = () => (
<Edit>
<SimpleForm showDisabled>
<TextInput source="reference" />
<TextInput source="width" />
<TextInput source="height" />
{/* disabled and not submitted */}
<TextInput source="description" />
{/* not displayed */}
<TextInput source="image" />
<TextInput source="thumbnail" />
{/* no delete button */}
</SimpleForm>
</Edit>
);
```

**Tip:** If both `showReadOnly` and `showDisabled` are set, `showDisabled` takes precedence.
34 changes: 33 additions & 1 deletion docs/TabbedForm.md
Original file line number Diff line number Diff line change
Expand Up @@ -1076,4 +1076,36 @@ const ProductEdit = () => (
</TabbedForm>
</Edit>
);
```
```

Read-only inputs are still included in the data submitted by the form. If you don't want to send these fields to the `dataProvider`, use the `showDisabled` prop instead. Inputs for which users have only `read` access will be displayed but disabled, and omitted from the submitted data:

```tsx
import { Edit, TextInput } from 'react-admin';
import { TabbedForm } from '@react-admin/ra-rbac';

const ProductEdit = () => (
<Edit>
<TabbedForm showDisabled>
<TabbedForm.Tab label="Description" name="description">
<TextInput source="reference" />
<TextInput source="width" />
<TextInput source="height" />
{/* Input Description is disabled and not submitted */}
<TextInput source="description" />
</TabbedForm.Tab>
{/* Tab Stock is not displayed */}
<TabbedForm.Tab label="Stock" name="stock">
<TextInput source="stock" />
</TabbedForm.Tab>
<TabbedForm.Tab label="Images" name="images">
{/* Input Image is not displayed */}
<TextInput source="image" />
<TextInput source="thumbnail" />
</TabbedForm.Tab>
</TabbedForm>
</Edit>
);
```

**Tip:** If both `showReadOnly` and `showDisabled` are set, `showDisabled` takes precedence.
Loading