CakePHP选择字段不填充
我使用的是CakePHP选择字段不填充,php,cakephp,cakephp-2.0,cakephp-2.3,Php,Cakephp,Cakephp 2.0,Cakephp 2.3,我使用的是cakephp2.3.8 我有两张桌子:应用程序,计算机应用程序。关系是一个应用程序有多个计算机应用程序,外键是应用程序id 在我的计算机应用程序模型中: class ComputerApplication extends AppModel{ public $name = "ComputerApplication"; public $useTable = "computer_application"; var $belongsTo =
cakephp2.3.8
我有两张桌子:应用程序,计算机应用程序。关系是一个应用程序
有多个计算机应用程序
,外键是应用程序id
在我的计算机应用程序模型中:
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
)
);
}
在我的计算机应用程序控制器中我在这里初始化**添加**
函数中的下拉列表填充
public function add($id=null) {
if (!$id) {
throw new NotFoundException(__('Invalid post'));
}
$this->set('computerApplications',
$this->ComputerApplication->Application->find('list',
array('fields' => array('description') ) ) );
}
现在在我的添加视图中
echo $this->Form->create("computerApplication");
echo $this->Form->input('application_id',array('empty'=>''));
echo $this->Form->end('Save Post');
我的问题是它不会填充select输入。这是我第一次使用cake在表[computer\u application
]中使用两个单词,因为我不会用一个单词填充其他表。请帮助我确定我需要调整哪些以填充它
$this->set('applications', ...
而不是
$this->set('computerApplications', ...