在 ArrayInput/SimpleFormIterator 中使用 ReferenceField
Use a ReferenceField inside of an ArrayInput/SimpleFormIterator
正如标题所说。我需要在 ArrayInput/SimpleFormIterator 中使用 ReferenceField。我不断收到以下错误:
TypeError: Cannot read property 'replace' of undefined
版本:
react-admin: 3.2.3
react: 16.12.0
这是代码片段:
<ArrayInput source="specialties" label="">
<SimpleFormIterator disableAdd>
<ReferenceField label="Specialties Link" source="ID" reference="specialty" link="show" >
<TextField source="ID" />
</ReferenceField>
<TextInput source="vendorSpecialtyText" label="Vendor Specialty Text" />
</SimpleFormIterator>
</ArrayInput>
有一个名为 specialty 的资源,它在应用程序其他部分的 ArrayField 内部工作,如下所示:
<ArrayField source="specialties" label=" Specialties">
<SingleFieldList>
<ReferenceField label="Specialties Link" source="ID" reference="specialty" link="show" >
<TextField source="ID" />
</ReferenceField>
</SingleFieldList>
</ArrayField>
不确定这是否在此框架内是不可能的,或者我是否实施错误。如果有解决此问题的方法或其他想要解决此问题的方法,请告诉我!谢谢。
Note: SimpleFormIterator
only accepts Input
components as children. If you want to use some Fields
instead, you have to use a <FormDataConsumer>
to get the correct source,..."
import { ArrayInput, SimpleFormIterator, DateInput, TextInput, FormDataConsumer } from 'react-admin';
<ArrayInput source="backlinks">
<SimpleFormIterator disableRemove >
<DateInput source="date" />
<FormDataConsumer>
{({ getSource, scopedFormData }) => {
return (
<TextField
source={getSource('url')}
record={scopedFormData}
/>
);
}}
</FormDataConsumer>
</SimpleFormIterator>
</ArrayInput>
或包括输入字段
<ArrayInput source="specialties" label="">
<SimpleFormIterator disableAdd>
<ReferenceInput label="Specialties Link" source="ID" reference="specialty">
<SelectInput optionText="{Your description field}" />
</ReferenceInput>
<TextInput source="vendorSpecialtyText" label="Vendor Specialty Text" />
</SimpleFormIterator>
</ArrayInput>
正如标题所说。我需要在 ArrayInput/SimpleFormIterator 中使用 ReferenceField。我不断收到以下错误:
TypeError: Cannot read property 'replace' of undefined
版本:
react-admin: 3.2.3
react: 16.12.0
这是代码片段:
<ArrayInput source="specialties" label="">
<SimpleFormIterator disableAdd>
<ReferenceField label="Specialties Link" source="ID" reference="specialty" link="show" >
<TextField source="ID" />
</ReferenceField>
<TextInput source="vendorSpecialtyText" label="Vendor Specialty Text" />
</SimpleFormIterator>
</ArrayInput>
有一个名为 specialty 的资源,它在应用程序其他部分的 ArrayField 内部工作,如下所示:
<ArrayField source="specialties" label=" Specialties">
<SingleFieldList>
<ReferenceField label="Specialties Link" source="ID" reference="specialty" link="show" >
<TextField source="ID" />
</ReferenceField>
</SingleFieldList>
</ArrayField>
不确定这是否在此框架内是不可能的,或者我是否实施错误。如果有解决此问题的方法或其他想要解决此问题的方法,请告诉我!谢谢。
Note:
SimpleFormIterator
only acceptsInput
components as children. If you want to use someFields
instead, you have to use a<FormDataConsumer>
to get the correct source,..."
import { ArrayInput, SimpleFormIterator, DateInput, TextInput, FormDataConsumer } from 'react-admin';
<ArrayInput source="backlinks">
<SimpleFormIterator disableRemove >
<DateInput source="date" />
<FormDataConsumer>
{({ getSource, scopedFormData }) => {
return (
<TextField
source={getSource('url')}
record={scopedFormData}
/>
);
}}
</FormDataConsumer>
</SimpleFormIterator>
</ArrayInput>
或包括输入字段
<ArrayInput source="specialties" label="">
<SimpleFormIterator disableAdd>
<ReferenceInput label="Specialties Link" source="ID" reference="specialty">
<SelectInput optionText="{Your description field}" />
</ReferenceInput>
<TextInput source="vendorSpecialtyText" label="Vendor Specialty Text" />
</SimpleFormIterator>
</ArrayInput>