File tree Expand file tree Collapse file tree 3 files changed +40
-16
lines changed
packages/ra-ui-materialui/src/input/ArrayInput Expand file tree Collapse file tree 3 files changed +40
-16
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ Check [the `<SimpleFormIterator>` documentation](./SimpleFormIterator.md) for de
8484
8585## Props
8686
87- ` <ArrayInput> ` accepts the [ common input props] ( ./Inputs.md#common-input-props ) (except ` format ` and ` parse ` ).
87+ ` <ArrayInput> ` accepts the [ common input props] ( ./Inputs.md#common-input-props ) (except ` disabled ` , ` readOnly ` , ` format ` and ` parse ` ).
8888
8989## Global validation
9090
@@ -109,3 +109,27 @@ You need to return an errors object shaped like this:
109109```
110110
111111** Tip:** You can find a sample ` validate ` function that handles arrays in the [ Form Validation documentation] ( ./Validation.md#global-validation ) .
112+
113+ ## Disabling The Input
114+
115+ ` <ArrayInput> ` does not support the ` disabled ` and ` readOnly ` props.
116+
117+ If you need to disable the input, set the ` <SimpleFormIterator disabled> ` prop, and make the child inputs ` readOnly ` :
118+
119+ ``` jsx
120+ const OrderEdit = () => (
121+ < Edit>
122+ < SimpleForm>
123+ < TextInput source= " customer" / >
124+ < DateInput source= " date" / >
125+ < ArrayInput source= " items" >
126+ < SimpleFormIterator inline disabled>
127+ < TextInput source= " name" readOnly/ >
128+ < NumberInput source= " price" readOnly / >
129+ < NumberInput source= " quantity" readOnly / >
130+ < / SimpleFormIterator>
131+ < / ArrayInput>
132+ < / SimpleForm>
133+ < / Edit>
134+ );
135+ ```
Original file line number Diff line number Diff line change @@ -117,11 +117,11 @@ export const Disabled = () => (
117117 >
118118 < SimpleForm >
119119 < TextInput source = "title" />
120- < ArrayInput source = "authors" disabled >
121- < SimpleFormIterator >
122- < TextInput source = "name" />
123- < TextInput source = "role" />
124- < TextInput source = "surname" />
120+ < ArrayInput source = "authors" >
121+ < SimpleFormIterator disabled >
122+ < TextInput source = "name" disabled />
123+ < TextInput source = "role" disabled />
124+ < TextInput source = "surname" disabled />
125125 </ SimpleFormIterator >
126126 </ ArrayInput >
127127 </ SimpleForm >
@@ -150,11 +150,11 @@ export const ReadOnly = () => (
150150 >
151151 < SimpleForm >
152152 < TextInput source = "title" />
153- < ArrayInput source = "authors" readOnly >
154- < SimpleFormIterator >
155- < TextInput source = "name" />
156- < TextInput source = "role" />
157- < TextInput source = "surname" />
153+ < ArrayInput source = "authors" >
154+ < SimpleFormIterator disabled >
155+ < TextInput source = "name" readOnly />
156+ < TextInput source = "role" readOnly />
157+ < TextInput source = "surname" readOnly />
158158 </ SimpleFormIterator >
159159 </ ArrayInput >
160160 </ SimpleForm >
Original file line number Diff line number Diff line change @@ -85,8 +85,6 @@ export const ArrayInput = (props: ArrayInputProps) => {
8585 source : arraySource ,
8686 validate,
8787 variant,
88- disabled,
89- readOnly,
9088 margin = 'dense' ,
9189 ...rest
9290 } = props ;
@@ -246,11 +244,13 @@ export const getArrayInputError = error => {
246244} ;
247245
248246export interface ArrayInputProps
249- extends CommonInputProps ,
250- Omit < FormControlProps , 'defaultValue' | 'onBlur' | 'onChange' > {
247+ extends Omit < CommonInputProps , 'disabled' | 'readOnly' > ,
248+ Omit <
249+ FormControlProps ,
250+ 'defaultValue' | 'disabled' | 'readOnly' | 'onBlur' | 'onChange'
251+ > {
251252 className ?: string ;
252253 children : ReactElement ;
253- disabled ?: boolean ;
254254 isFetching ?: boolean ;
255255 isLoading ?: boolean ;
256256 isPending ?: boolean ;
You can’t perform that action at this time.
0 commit comments