我想在cakephp的数据库中保存一些数据 这是我的模板......
echo $this->Form->create();
echo $this->Form->input('outtime',
array(
'class' => 'outtime',
'id' => 'outtime',
'name' => 'outtime'
)
);
echo $this->Form->input('out date',
array(
'class' => 'datepicker0',
'id' => 'outdate',
'name' => 'outdate'
)
);
echo $this->Form->input('return date',
array(
'class' => 'datepicker0',
'id' => 'returndate',
'name' => 'returndate'
)
);
echo $this->Form->button(__('submit'));
echo $this->Form->end();
这是我的数据库模板。
当我使用保存功能时它不起作用我在我的代码上使用了调试功能......
if ($this->Outs->save($out)) {
$this->Flash->success(__('The out has been saved.'));
} else {
debug($out->errors()); die;
$this->Flash->error(__('The out could not be saved. Please, try again.'));
}
当我运行它时结果是
我的完整方法代码...... public function addout()
{
$uid = $this->Auth->User()['id'];
$out = $this->Outs->newEntity();
if ($this->request->is('post')) {
$out = $this->Outs->patchEntity($out, $this->request->data);
$this->request->data['user_id'] = $uid;
}
if ($this->Outs->save($out)) {
$this->Flash->success(__('The out has been saved.'));
} else {
debug($this->request->data); exit;
$this->Flash->error(__('The out could not be saved. Please, try again.'));
}
}
我的调试输出是...... debug out put 我希望这些信息可以帮到你。 我不知道有关此错误的任何事情,请帮助我