我尝试从cakephp 3表单中保存数据.所有数据都保存得很好,但日期时间没有.我有2个日期时间字段.这些字段由jquery-ui小部件填充.
在实体化时,似乎发生了这个问题.
$intervention = $this->Interventions->patchEntity($intervention, $this->request->data);
Run Code Online (Sandbox Code Playgroud)
调试$ this-> request-> data:
'user_id' => '1',
'description' => 'test',
'starttime' => '2015/11/15 10:00',
'endtime' => '2015/11/15 12:10'
Run Code Online (Sandbox Code Playgroud)在pacthEntity之后调试我的对象$干预:
对象(应用程序\模型\实体\干预)
'id' => (int) 3,
'user_id' => (int) 1,
'description' => 'test',
'starttime' => null,
'endtime' => null
...
Run Code Online (Sandbox Code Playgroud)
starttime和endtime变为null,我不明白为什么.
有人曾经有过这个pb吗?
我尝试(用于调试和理解)强制字段值,然后在mysql中修补和datetime字段都可以.
$intervention->starttime = date('Y-m-d H:i:s', strtotime($this->request->data['starttime']));
$intervention->endtime = date('Y-m-d H:i:s', strtotime($this->request->data['endtime']));
Run Code Online (Sandbox Code Playgroud)
感谢帮助
datetime cakephp marshalling internationalization cakephp-3.0