如何获取 SimpleFormIterator 的索引

Can*_*uti 5 admin-on-rest react-admin

我想访问 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>
Run Code Online (Sandbox Code Playgroud)

Gil*_*cia 1

这是不可能的SimpleFormIterator。你必须自己写。我建议使用它作为基础(https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/form/SimpleFormIterator.js)并在克隆输入时传递索引在L114