Skip to content

Commit 18cb162

Browse files
committed
Add ArrayInput story to test inputs default values
1 parent 68129be commit 18cb162

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

packages/ra-ui-materialui/src/input/ArrayInput/ArrayInput.stories.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,44 @@ export const ReadOnly = () => (
173173
</TestMemoryRouter>
174174
);
175175

176+
export const DefaultValues = () => (
177+
<TestMemoryRouter initialEntries={['/books/1']}>
178+
<Admin dataProvider={dataProvider}>
179+
<Resource
180+
name="books"
181+
edit={() => {
182+
return (
183+
<Edit
184+
mutationMode="pessimistic"
185+
mutationOptions={{
186+
onSuccess: data => {
187+
console.log(data);
188+
},
189+
}}
190+
>
191+
<SimpleForm>
192+
<TextInput source="title" />
193+
<ArrayInput source="authors">
194+
<SimpleFormIterator>
195+
<TextInput
196+
source="name"
197+
defaultValue="John Doe"
198+
/>
199+
<TextInput
200+
source="role"
201+
defaultValue="Author"
202+
/>
203+
</SimpleFormIterator>
204+
</ArrayInput>
205+
</SimpleForm>
206+
</Edit>
207+
);
208+
}}
209+
/>
210+
</Admin>
211+
</TestMemoryRouter>
212+
);
213+
176214
const BookEditWithAutocomplete = () => {
177215
return (
178216
<Edit

0 commit comments

Comments
 (0)