我有一个POST模型和一个COMMENT模型。在我的Comments元素中,我正在从URL中检索POST_ID,该工作正常。
现在我在主页上调用POST和COMMENT元素,但是当我添加注释时,它没有从URL获取id,因为URL现在是/ home而不是/ post / view / id。
我该如何解决这个问题?
这就是我从网址
中检索ID的方式$id = $this->request['pass'][0];
echo $this->form->input('note_id', array('type'=>'hidden', 'value'=>$id));
答案 0 :(得分:0)
当您显示帖子和评论时,您可能有$posts['Post']
和$comments['Comment']
这样的数组,所以为了获得post_id,您可以使用$posts['Post']['id']
您可以设置的ID
echo $this->form->input('note_id', array('type'=>'hidden', 'value'=>$posts['Post']['id']));