php - CakePHP 3.0 dev. Model Save() error? -
i try save input data , in line of save() method show me error , controller register method :
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 ')); } }
and error :
error: call member function isnew() on non-object file c:\wamp\www\vendor\cakephp\cakephp\src\orm\table.php line: 1092
i mention i'm sure model name'helloworlds' idea?
at least find out answer , true code :
public function register() { if ($this->request->is('post')) { $helloworld = tableregistry::get('helloworlds'); $helloworlds = $helloworld->newentity($this->request->data); if ($helloworld->save($helloworlds)) { $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 ')); } } }
Comments
Post a Comment