HABTM dropdown items not selected

前端 未结 2 1258
暖寄归人
暖寄归人 2021-01-25 10:19

I created a site for fun to learn CakePHP but for some reason I can\'t get a multiple select dropdown box to show my selected items. In this example 1 video game can have multip

相关标签:
2条回答
  • 2021-01-25 10:50

    For everyone who sets public $recursive = -1; in his AppModel due to performance reasons, or changes the recursion in his controller: The automagic won't work without recursive 1! Make sure you change it in the options when retreiving your data for the edit.

    $options = array(
        'recursive' => 1,
        'conditions' => array('YourModel.' . $this->YourModel->primaryKey => $id)
    );
    $this->request->data = $this->YourModel->find('first', $options);
    
    0 讨论(0)
  • 2021-01-25 11:01

    What CakePHP version are you using? Releases 2.2.6 and 2.3.0 have a bug related to showing existing habtm selected. So updated to 2.2.7 if using 2.2.6 or if using 2.3.0 use the master branch from github until the next bugfix release is done.

    0 讨论(0)
提交回复
热议问题