我在Edit视图中有一个ArrayInput。
<Edit undoable={false} {...props} title={<AdTitle />} >
<TabbedForm>
<FormTab label="summary">
<ArrayInput source="siteads" addLabel={false}>
<SimpleFormIterator disableRemove disableAdd>
{ record.status === 0 && <TextInput label="Hivatkozas" source="href" props={{ disabled: true }}/> }
</SimpleFormIterator>
</ArrayInput>
</FormTab>
</TabbedForm>
</Edit>
如何在“编辑”视图中获取记录的字段/值?
答案 0 :(得分:1)
这里还将使用FormDataConsumer,这是文档中的示例:
“您正在ArrayInput内使用FormDataConsumer,但没有调用FormDataConsumer组件提供的getSource函数。这是您的输入获取正确源所必需的”
<ArrayInput source="users">
<SimpleFormIterator>
<TextInput source="name" />
<FormDataConsumer>
{({
formData, // The whole form data
scopedFormData, // The data for this item of the ArrayInput
getSource, // A function to get the valid source inside an ArrayInput
...rest,
}) =>
scopedFormData.name ? (
<SelectInput
source={getSource('role')} // Will translate to "users[0].role"
choices={['admin', 'user']}
{...rest}
/>
) : null
}
</FormDataConsumer>
</SimpleFormIterator>
</ArrayInput>