我使用ReferenceManyField来显示订单中的项目,这是典型的主/详细数据库模式。我可以编辑现有的详细记录,但找不到添加新详细记录的方法。我尝试了以下方法,但没有像这样收到{id}。我注意到admin-on-rest-demo允许编辑详细记录(产品评论),但不允许添加评论。有没有这样做的模式或变通方法?
<SimpleForm>
<ReferenceManyField label="ITEMS" reference="orderitems" target="orderId">
<Datagrid>
// fields removed for clarity...
<CreateButton/> <===== does not pass {id} of form record
<EditButton/> <===== passes {id} of form record
</Datagrid>
</ReferenceManyField>
</SimpleForm>发布于 2018-04-24 03:30:02
我回答了这个问题here
示例:https://codesandbox.io/s/pp0o4x40p0
相关代码部分如下:
CreateCommentButton component inside src/posts.jsCommentCreate component inside src/comments.js (注意我们如何在SimpleForm)上设置defaultValue属性
https://stackoverflow.com/questions/49983952
复制相似问题