Monday, April 28, 2014

Re: cake 3 - issue saving null datetime

Sounds like the case here.
You maybe should open a github issue regarding this.

Am Montag, 28. April 2014 10:15:44 UTC+2 schrieb bato:
Hi all,

I have a table with a field 'date_start' that can be nullable. I have a fatal error when try to save null value on db.
In my controller I have:

$data['start_date'] = null;
$c = TableRegistry::get('Contents');
$e = $c->newEntity($data);
$c->save($e);

and the fatal error is

Error: Call to a member function format() on a non-object
File /..../vendor/cakephp/cakephp/src/Database/Type/DateTimeType.php
Line: 62

I think there is a bug because the  Cake\Database\Type\DateTimeType::toDatabase($value, Driver $driver) method doesn't check if $value is null and try to use a method on it $value->format($this->_format);

Is it a bug?

alberto

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: