首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >admin-on-rest CreateButton未传递表单的记录id

admin-on-rest CreateButton未传递表单的记录id
EN

Stack Overflow用户
提问于 2018-04-23 22:48:33
回答 1查看 18关注 0票数 0

我使用ReferenceManyField来显示订单中的项目,这是典型的主/详细数据库模式。我可以编辑现有的详细记录,但找不到添加新详细记录的方法。我尝试了以下方法,但没有像这样收到{id}。我注意到admin-on-rest-demo允许编辑详细记录(产品评论),但不允许添加评论。有没有这样做的模式或变通方法?

代码语言:javascript
复制
   <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>
EN

回答 1

Stack Overflow用户

发布于 2018-04-24 03:30:02

我回答了这个问题here

示例:https://codesandbox.io/s/pp0o4x40p0

相关代码部分如下:

  • CreateCommentButton component inside src/posts.js
  • the CommentCreate component inside src/comments.js (注意我们如何在SimpleForm)

上设置defaultValue属性

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49983952

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档