Hi, did somebody recognized already, that patchEntity might set a field (datefield) to NULL (probably during internal validation, may get more into details soon) ? It is also strange the the field is set dirty even the field have not changed or touched ?
DB error, constraint violation (cause NULL): request edit and just submit, leds to pickup NULL after patchEntity
No exception: request edit, just change one single field on the form gives correct value of pickup
controller:
$order = $this->Orders->patchEntity($order, $this->request->getData());
debug($this->request->getData());
debug($order);
exit; // only for debug
if ($this->Orders->save($order)) { // <== Exception of course because pickup is NULL)
template:
… form create …
echo $this->Form->control('pickup');
… form new
OUTPUT:
debug($this->request->getData());
[
‘user_id’ => ‘2’,
‘destination’ => ‘d’,
‘freetext’ => ‘df’,
‘pickup’ => ‘2020-05-21T10:10:20.000’,
‘orderstatus_id’ => ‘1’
]
debug($order);
object(App\Model\Entity\Order) {
'id' => (int) 12,
'user_id' => (int) 2,
'destination' => 'd',
'freetext' => 'df',
'pickup' => null,
'orderstatus_id' => (int) 1,
'modified' => object(Cake\I18n\FrozenTime) {
'time' => '2020-02-27 00:25:38.000000+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'created' => object(Cake\I18n\FrozenTime) {
'time' => '2020-02-27 00:25:38.000000+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'[new]' => false,
'[accessible]' => [
'user_id' => true,
'destination' => true,
'freetext' => true,
'pickup' => true,
'orderstatus_id' => true,
'modified' => true,
'created' => true,
'user' => true,
'orderitem' => true,
'orderstatus' => true
],
'[dirty]' => [
**‘pickup’ => true
],
‘[original]’ => [
‘pickup’ => object(Cake\I18n\FrozenTime) {
'time' => '2020-05-21 10:10:20.000000+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
}
],
'[virtual]' => [],
'[hasErrors]' => false,
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'Orders'
}