0

我在用着cakePHP 2.3.8

我有两个表:application,computer_application。关系是一个applicationhasMany 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控制器中。这里我在函数中初始化了 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使用 cake 在表 [ ] 中使用 2 个单词,因为我只用一个单词填充其他表没有问题。只需帮助我确定我需要调整哪些才能填充它。

4

1 回答 1

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

并不是

$this->set('computerApplications', ...
于 2013-10-02T04:12:19.177 回答