我正在尝试编辑公司并更新 umusers 表中的密码。如果我使用 save 它会更新公司,但不会更新 umusers 表中的密码。如果我使用 saveAll 它会在 umusers 表中创建一个新用户。
这是我的设置
公司模式我有:
public $hasOne = 'Umuser';
公司控制人
public function edit($id = null) {
$this->Company->id = $id;
if (!$this->Company->exists()) {
throw new NotFoundException(__('Invalid company'));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->Company->save($this->request->data)) {
$this->Session->setFlash(__('The company has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The company could not be saved. Please, try again.'));
}
} else {
$this->request->data = $this->Company->read(null, $id);
}
}
$this->request->data 的 var_dump:
array(2) { ["Company"]=> array(12) { ["id"]=> string(3) "157" ["member_number"]=> string(6) "234234" ["name"]=> string(5) "keith" ["address1"]=> string(5) "keith" ["address2"]=> string(5) "keith" ["county"]=> string(5) "keith" ["limited"]=> string(1) "0" ["tax_number"]=> string(5) "keith" ["contact_name"]=> string(5) "keith" ["phone"]=> string(5) "keith" ["email"]=> string(15) "keith@keith.com" ["payment_start"]=> array(3) { ["month"]=> string(2) "02" ["day"]=> string(2) "01" ["year"]=> string(4) "2013" } } ["Umuser"]=> array(1) { ["password"]=> string(6) "keith1" } }
我知道目前我不会散列密码或取消设置它是否留空。我错过了什么,也许与 id 有某种关系?