cakephp 211保存数据错误(关联表)

时间:2012-05-14 23:05:00

标签: cakephp-2.1

我有两个关联的表(客户有很多命令),这是我的表格:

<?php echo $this->Form->create('Customer');?>
echo $this->Form->input('Client.name', array('disabled' => true,'value' =>  'francis')); 
echo $this->Form->input('Command.0.the_date');
echo $this->Form->end(__('save'));?>

这是我的功能:

public function add() {
    if (!empty($this->request->data)) {
        unset($this->Customer->Command->validate['customers_id']);
        $this->Customer->saveAssociated($this->request->data);    
    }
}

但是当我处理保存数据时,没有任何反应! 为什么? 谢谢!

1 个答案:

答案 0 :(得分:0)

请在您的控制器上使用此行

var $uses = array('Customer','Command');

public function add() {
    if (!empty($this->request->data)) {
        unset($this->Customer->Command->validate['customers_id']);
        $this->Customer->saveall($this->request->data);    
    }
}