0
これは私のコードです。私は単純な保存を行うことに問題があります。メッセージは、私はこれが私のテーブルである[cakePHP3]失敗した保存をデバッグする方法
$user = $this->Users->newEntity();
if($this->request->is('post'))
{
$user = $this->Users->patchEntity($user, $this->request->data);
if($this->Users->save($user))
{
$this->Flash->success(':)');
return $this->redirect(['controller' => 'Users', 'action' => 'index']);
}
else
{
$this->Flash->error(':(');
}
debug($this->request->data);
}
$this->set(compact('user'));
を保存しようとしたとき:(ですが、私は移行しました。すべてのフィールドがnullになることができ、これは私の要求データである
$table = $this->table('users');
$table->addColumn('first_name','string',array('limit'=>100))
->addColumn('last_name','string',array('limit'=>100))
->addColumn('email','string',array('limit'=>100))
->addColumn('password','string')
->addColumn('role','enum',array('values'=>'admin,user'))
->addColumn('active','boolean')
->addColumn('created','datetime')
->addColumn('modified','datetime')
->create();
[
'first_name' => 'wewe',
'last_name' => 'wewe',
'email' => '[email protected]',
'password' => 'wewewe',
'role' => 'admin',
'active' => '1'
]
あなたが私を助けてくれることを願っています。私は非常に不満です。
EDIT:print_r($ user-> errors());を使用しています。私はこれを取得...
Array ([firts_name] => Array ([_required] => This field is required))
youuuuuuuuuuuuuuuuuuuuuuuuuuuuに –
グッドキャッチタイプミスに感謝:) –