Skip to content

Commit 36b1232

Browse files
committed
added a dedicated validation section
1 parent 6f3ed5c commit 36b1232

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

docs/ReferenceArrayInput.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ See the [`children`](#children) section for more details.
113113

114114
**Note**: `<ReferenceArrayInput>` doesn't accept the [common input props](./Inputs.md#common-input-props) ; it is the responsability of children to apply them. The same is true for validation: put the `validate` prop on the child input (`<AutocompleteArrayInput>`, `<SelectArrayInput>`, `<DualListInput>`, etc.), not on `<ReferenceArrayInput>`.
115115

116+
## Validation
117+
118+
`<ReferenceArrayInput>` doesn't accept a `validate` prop. Put validation on the child input instead (`<AutocompleteArrayInput>`, `<SelectArrayInput>`, `<DualListInput>`, etc.).
119+
120+
```jsx
121+
import { ReferenceArrayInput, SelectArrayInput, required } from 'react-admin';
122+
123+
<ReferenceArrayInput source="tag_ids" reference="tags">
124+
<SelectArrayInput validate={required()} />
125+
</ReferenceArrayInput>
126+
```
127+
116128
## `children`
117129

118130
By default, `<ReferenceArrayInput>` renders an [`<AutocompleteArrayInput>`](./AutocompleteArrayInput.md) to let end users select the reference record.

docs/ReferenceInput.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ See the [`children`](#children) section for more details.
116116

117117
**Note**: `<ReferenceInput>` doesn't accept the [common input props](./Inputs.md#common-input-props) (like `label`) ; it is the responsibility of the child component to apply them. The same goes for validation: pass `validate` to the child input (`<AutocompleteInput>`, `<SelectInput>`, `<RadioButtonGroupInput>`, etc.), not to `<ReferenceInput>`. This also applies to other reference inputs like [`<ReferenceArrayInput>`](./ReferenceArrayInput.md).
118118

119+
## Validation
120+
121+
`<ReferenceInput>` doesn't accept a `validate` prop. Put validation on the child input instead (`<AutocompleteInput>`, `<SelectInput>`, `<RadioButtonGroupInput>`, etc.).
122+
123+
```jsx
124+
import { ReferenceInput, SelectInput, required } from 'react-admin';
125+
126+
<ReferenceInput source="company_id" reference="companies">
127+
<SelectInput validate={required()} />
128+
</ReferenceInput>
129+
```
130+
119131
## `children`
120132

121133
By default, `<ReferenceInput>` renders an [`<AutocompleteInput>`](./AutocompleteInput.md) to let end users select the reference record.

0 commit comments

Comments
 (0)