When I try to store NULL for a DateTime-field it always comes out as 0000-00-00 00:00:00. I have set up the schema and the database correctly in order to be able to store NULL values. (allowed "NULL" to be stored and even set the default value for those datetime-fields to NULL).
I tried:
1.) The "pre-binding"-approach (=> in the actions.class)
$values = $request->getParameter($form->getName());
$values['datetime_field'] = null;
$form->bind($values, $request->getFiles($form->getName()));
2.) The "pre-saving"-approach (=> in the ctions.class)
if ($form->isValid())
{
$form->getObject()->setDateTimeField(null);
$form->save();
3.) The "override updateObject()"-approach (=> in the forms-class)
public function updateObject($values = null)
{
$object = parent::updateObject($values);
$object->setDateTimeField(null);
return $object;
}
There must be something I haven't thought of... why is there always 0000-00-00 00:00:00 stored instead of NULL? Really "nothing" needs to be stored, so the DBMS could handle the "NULL-insertion" itself...
Any help/hint is HIGHLY appreciated! :)