0

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

<?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);    
    }
}

但是当我处理保存数据时,什么也没有发生!为什么?谢谢!

4

1 回答 1

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);    
    }
}
于 2014-08-14T14:14:59.160 回答