我是使用admin-on-rest
框架的新手,我需要使嵌套表格正常工作。
我有两个模特秀和song.show()可以有多首歌曲。我有显示编辑表单,它将按预期工作。
我需要在节目编辑表单中添加一个歌曲表单,这样我就可以为每个节目添加多首歌曲。
我尝试过所有方法,但我无法完成任务。
这是我的代码:
<Edit title="Edit Show" {...this.props}>
<SimpleField>
<TextInput source="name" style={{ display: 'inline-block' }} />
//here need to add song add form without reloading page
//this is songs grid
<ReferenceManyField reference="songs" target="show_id" label="Set List" perPage={5} >
<Datagrid>
<TextField source="song_name" />
<EditButton />
<DeleteButton />
</Datagrid>
</ReferenceManyField>
//Here need to add song form, so i can add songs
</SimpleField>
</Edit>
我怎样才能做到这一点?
答案 0 :(得分:1)
不确定是否能回答你的问题..如果歌曲预先存在,那么你只需要这样做:
<Edit title="Edit Show" {...this.props}>
<TextInput source="name" style={{ display: 'inline-block' }} />
<ReferenceArrayInput label="Songs" source="songs_property_on_show" reference="songs" allowEmpty>
<SelectArrayInput optionText="song_name" translate={false}/>
</ReferenceArrayInput>
</Edit>
如果您想在创建节目时动态创建它们,或者换句话说在另一个内部有一个表单,则需要以自定义方式(使用redux-form)完成,如我的问题所述:{ {3}}