0
我使用cakePHP 2.3.8
CakePHP選擇字段不填充
我有兩個表:application,computer_application。的關係是一個application
的hasMany computer_application
,外鍵是application_id
在我ComputerApplication 模式:
class ComputerApplication extends AppModel{
public $name = "ComputerApplication";
public $useTable = "computer_application";
var $belongsTo = array(
'Computer' => array(
'className' => 'Computer',
'foreignKey' => 'computer_id',
'dependent' => true
),
'Application' => array(
'className' => 'Application',
'foreignKey' => 'application_id',
'dependent' => true
)
);
}
在我ComputerApplication 控制器。 這裏我INITIALIZE DROPDOWN的人口**add**
功能
public function add($id=null) {
if (!$id) {
throw new NotFoundException(__('Invalid post'));
}
$this->set('computerApplications',
$this->ComputerApplication->Application->find('list',
array('fields' => array('description'))));
}
現在在我的Add
查看
echo $this->Form->create("computerApplication");
echo $this->Form->input('application_id',array('empty'=>''));
echo $this->Form->end('Save Post');
我的問題是,它不會填充選擇輸入。這是我第一次在表[computer_application
]中使用蛋糕中的2個單詞,因爲我沒有用一個單詞填充其他表的問題。只是幫助我確定我需要調整它來填充。
哇,我怎麼可能會錯過...感謝.. – Ikong