CakePHP 3.0开发模型保存()错误?

CakePHP 3.0开发模型保存()错误?,php,cakephp,Php,Cakephp,我只是尝试保存输入数据,在save()方法的行中显示错误,这是我的控制器寄存器方法: public function register() { if ($this->Helloworlds->save($this->request->data)) { $id = $this->Helloworld->id; $this->request->data['Helloworld'] = array_merge($t

我只是尝试保存输入数据,在save()方法的行中显示错误,这是我的控制器寄存器方法:

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 '));
    }
} 
错误是:

错误:对非对象文件调用成员函数isNew() C:\wamp\www\vendor\cakephp\cakephp\src\ORM\Table.php行:1092

我想提到这一点,我确信我的模型名为“helloworlds”
有什么想法吗?

至少我找到了答案,真正的代码是:

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

您确定
Helloworlds
正确吗?在所有其他命令中使用单数形式:
$this->Helloworld->id
$this->request->data['Helloworld']
。。。CakePHP命名约定(至少在2.x之前)将模型名强制为单数,而不是复数。我使用Helloworld和非对象错误,并测试了
$this->modelClass
,所以?抱歉?我不明白你想说什么。