我得到了一个名为Posts的控制器,这个名为Content的模型与其他模型(如Category和Location)正确链接。在cakephp中以编辑模式重新填充关系
在我的添加“内容”视图中,我成功填充了多个选择列表,其中包含要与帖子关联的类别和位置。保存完美的作品。
现在在编辑/更新模式下,我可以再次填充多个选项的类别和位置,但不会选择与当前文章相关的选择。在数据库中查看时,有些类别和位置已成功实现到当前帖子。
这是我在我的控制器有:
$this->data = $this->Content->read();
$this->set('locations',$this->Content->Location->find('list',array('fields' => array('id','location'))));
$this->set('categories',$this->Content->Category->find('list',array('fields' => array('id','category'))));
这是我在我的观点了:
echo $this->Form->input('Location', array('type' => 'select','multiple' => 'true','options' => $locations));
echo $this->Form->input('Category', array('type' => 'select','multiple' => 'true','options' => $categories));
缺少什么我在这里?我如何获得已经相关的位置和类别,请在多选列表中选择?
(非关系数据的填充,将重新填充文本框等只是完美)
感谢您的帮助!
杰森
工作,谢谢harpax! – Jason 2010-12-09 16:04:07