Save data to another model cakePHP 3.5

自闭症网瘾萝莉.ら 提交于 2019-12-02 10:02:25

Your data is in the wrong format. Where did you find this? It should look like this:

[
    'questions' => [
        '_ids' => [
            0 => 60,
            1 => 61,
        ]
    ]
]

Note that questions is now lower case and plural, and id is replaced with _ids. See here for more details.

You will also want to move this to the Quizzes controller (as I suggested last time) and do patchEntity on a quiz entity (through the Quizzes model), because right now the data you have is meaningless: how does it know what quiz it's supposed to be adding these questions to?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!