我想访问simpleFormIterator的索引。我怎样才能做到这一点?
我有这样的代码
我正在尝试在SelectInput组件中访问它
<ArrayInput source='services'>
<SimpleFormIterator>
<TextInput source='id' label="Service Name" validate={this.RequiredAndRegex} />
<FormDataConsumer>
{({ formData, ...rest }) =>
<ArrayInput source='parametervalues'>
<SimpleFormIterator>
<TextInput source='id' label="Parameter Values" validate={this.RequiredAndRegex} />
<SelectInput label="Paramater Type"
source="id"
choices={this.getParameters(formData.services[index].servicetype)}
optionText={optionRenderer}
optionValue="id" />
</SimpleFormIterator>
</ArrayInput>
}
</FormDataConsumer>
</SimpleFormIterator>
</ArrayInput>
最佳答案
SimpleFormIterator
是不可能的。您必须自己编写。我建议将其用作基础(https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/form/SimpleFormIterator.js)并在L114处克隆输入时传递索引