Skip to content

Commit 7e61cca

Browse files
authored
Merge pull request #9864 from marmelab/forms-doc
[Doc] Add Forms dedicated chapter
2 parents 63536b4 + 9411364 commit 7e61cca

15 files changed

+791
-481
lines changed

docs/AccordionForm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export const PostCreate = () => (
165165

166166
**Tip**: You can include properties in the form `defaultValues` that are not listed as input components, like the `created_at` property in the previous example.
167167

168-
**Tip**: React-admin also allows to define default values at the input level. See the [Setting default Values](./EditTutorial.md#setting-default-values) section.
168+
**Tip**: React-admin also allows to define default values at the input level. See the [Setting default Values](./Forms.md#default-values) section.
169169

170170
## `id`
171171

docs/EditTutorial.md

Lines changed: 9 additions & 472 deletions
Large diffs are not rendered by default.

docs/Features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ These building blocks include:
11331133
And if you want to create your building blocks, you can use any of the [75+ hooks](./Reference.md#hooks) that carry **headless, reusable logic**. To name a few of them:
11341134

11351135
- [`useRecordContext`](./useRecordContext.md) to get the current record anywhere in the app
1136-
- [`useWarnWhenUnsavedChanges`](./EditTutorial.md#warning-about-unsaved-changes) to warn the user when he tries to leave a page with unsaved changes
1136+
- [`useWarnWhenUnsavedChanges`](./Forms.md#warning-about-unsaved-changes) to warn the user when he tries to leave a page with unsaved changes
11371137
- [`useSaveContext`](./useSaveContext.md) to tweak form submission
11381138
- [`useTheme`](./useTheme.md) to change the theme programmatically
11391139

docs/Form.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const PostCreate = () => (
8383

8484
**Tip**: You can include properties in the form `defaultValues` that are not listed as input components, like the `created_at` property in the previous example.
8585

86-
**Tip**: React-admin also allows to define default values at the input level. See the [Setting default Values](./EditTutorial.md#setting-default-values) section.
86+
**Tip**: React-admin also allows to define default values at the input level. See the [Setting default Values](./Forms.md#default-values) section.
8787

8888
## `id`
8989

docs/Forms.md

Lines changed: 768 additions & 0 deletions
Large diffs are not rendered by default.

docs/Inputs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ If `true`, the input is disabled and the user can't change the value.
158158
<TextInput source="title" disabled />
159159
```
160160

161-
**Tip**: The form framework used by react-admin, react-hook-form, [considers](https://github.com/react-hook-form/react-hook-form/pull/10805) that a `disabled` input shouldn't submit any value. So react-hook-form sets the value of all `disabled` inputs to `undefined`. As a consequence, a form with a `disabled` input is always considered `dirty` (i.e. react-hook-form considers that the form values and the initial record values are different), and it triggers [the `warnWhenUnsavedChanges` feature](./EditTutorial.md#warning-about-unsaved-changes) when leaving the form, even though the user changed nothing. The workaround is to set the `disabled` prop on the underlying input component, as follows:
161+
**Tip**: The form framework used by react-admin, react-hook-form, [considers](https://github.com/react-hook-form/react-hook-form/pull/10805) that a `disabled` input shouldn't submit any value. So react-hook-form sets the value of all `disabled` inputs to `undefined`. As a consequence, a form with a `disabled` input is always considered `dirty` (i.e. react-hook-form considers that the form values and the initial record values are different), and it triggers [the `warnWhenUnsavedChanges` feature](./Forms.md#warning-about-unsaved-changes) when leaving the form, even though the user changed nothing. The workaround is to set the `disabled` prop on the underlying input component, as follows:
162162

163163
{% raw %}
164164
```jsx

docs/LongForm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export const PostCreate = () => (
147147

148148
**Tip**: You can include properties in the form `defaultValues` that are not listed as input components, like the `created_at` property in the previous example.
149149

150-
**Tip**: React-admin also allows to define default values at the input level. See the [Setting default Values](./EditTutorial.md#setting-default-values) section.
150+
**Tip**: React-admin also allows to define default values at the input level. See the [Setting default Values](./Forms.md#default-values) section.
151151

152152
## `id`
153153

docs/Reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ title: "Index"
323323
* [`useUpdateMany`](./useUpdateMany.md)
324324

325325
**- W -**
326-
* [`useWarnWhenUnsavedChanges`](./EditTutorial.md#warning-about-unsaved-changes)
326+
* [`useWarnWhenUnsavedChanges`](./Forms.md#warning-about-unsaved-changes)
327327
* [`withLifecycleCallbacks`](./withLifecycleCallbacks.md)
328328

329329
</div>

docs/SimpleForm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const PostCreate = () => (
108108

109109
**Tip**: You can include properties in the form `defaultValues` that are not listed as input components, like the `created_at` property in the previous example.
110110

111-
**Tip**: React-admin also allows to define default values at the input level. See the [Setting default Values](./EditTutorial.md#setting-default-values) section.
111+
**Tip**: React-admin also allows to define default values at the input level. See the [Setting default Values](./Forms.md#default-values) section.
112112

113113
## `id`
114114

docs/TabbedForm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const PostCreate = () => (
150150

151151
**Tip**: You can include properties in the form `defaultValues` that are not listed as input components, like the `created_at` property in the previous example.
152152

153-
**Tip**: React-admin also allows to define default values at the input level. See the [Setting default Values](./EditTutorial.md#setting-default-values) section.
153+
**Tip**: React-admin also allows to define default values at the input level. See the [Setting default Values](./forms.md#default-values) section.
154154

155155
## `id`
156156

0 commit comments

Comments
 (0)