-1
我只是儘量節省輸入數據和保存線()方法告訴我的錯誤,這是我的控制寄存器方法:CakePHP 3.0 dev。模型保存()錯誤?
public function register() {
if ($this->Helloworlds->save($this->request->data)) {
$id = $this->Helloworld->id;
$this->request->data['Helloworld'] = array_merge($this->request->data['Helloworld'], array('id' => $id));
$this->Auth->login($this->request->data['Helloworld']);
return $this->redirect('/helloworld/index');
}
else
{
$this->Session->setFlash(__('Sorry no data has saved '));
}
}
和錯誤:
Error: Call to a member function isNew() on a non-object File C:\wamp\www\vendor\cakephp\cakephp\src\ORM\Table.php Line: 1092
我會提到這一點,我確定我的模特名字'helloworlds' 有什麼想法?
你確定'Helloworlds'是正確的?在所有其他命令中使用單數:'$ this-> Helloworld-> id;',$ this-> request-> data ['Helloworld']'... CakePHP命名約定(至少在2.x之前)以單數形式實施模型名稱,而不是複數形式。 – mathielo
我使用Helloworld和非對象錯誤,並且我測試了''$ this-> modelClass'',所以? –
對不起?我不明白你想說什麼。 – mathielo