2017-10-05 19 views
1

我是新使用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

你应该显示你正在遇到的确切问题。不要让我们猜测。 – jdv

+1

更改了问题以提高质量 – Kalamarico

回答

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> 

如果要动态地创建他们,而你正在创建的节目或其他词有一种形式在另一个这需要以自定义的方式(使用REDX形式)在我的问题下评论:how to create an entity inside another in the same form using admin-on-rest?