2013-10-02 89 views
0

我使用cakePHP 2.3.8CakePHP選擇字段不填充

我有兩個表: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個單詞,因爲我沒有用一個單詞填充其他表的問題。只是幫助我確定我需要調整它來填充。

回答

2
$this->set('applications', ... 

,而不是

$this->set('computerApplications', ... 
+0

哇,我怎麼可能會錯過...感謝.. – Ikong