diff --git a/src/MetaModels/DcGeneral/Data/Driver.php b/src/MetaModels/DcGeneral/Data/Driver.php index cd0e07817..d07f27354 100644 --- a/src/MetaModels/DcGeneral/Data/Driver.php +++ b/src/MetaModels/DcGeneral/Data/Driver.php @@ -18,6 +18,7 @@ * @author David Molineus * @author binron * @author Sven Baumann + * @author Richard Henkenjohann * @copyright 2012-2018 The MetaModels team. * @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later * @filesource @@ -304,7 +305,7 @@ public function getEmptyConfig() */ public function getEmptyModel() { - $objItem = new Item($this->getMetaModel(), array()); + $objItem = new Item($this->getMetaModel(), null); return new Model($objItem); } diff --git a/src/MetaModels/Item.php b/src/MetaModels/Item.php index 05033258b..1df98831c 100644 --- a/src/MetaModels/Item.php +++ b/src/MetaModels/Item.php @@ -61,10 +61,19 @@ class Item implements IItem * * @param IMetaModel $objMetaModel The model this item is represented by. * - * @param array $arrData The initial data that shall be injected into the new instance. + * @param array|null $arrData The initial data that shall be injected into the new instance. */ public function __construct(IMetaModel $objMetaModel, $arrData) { + if (null === $arrData) { + // Initialize attributes with empty values. + $arrData = []; + + foreach ($objMetaModel->getAttributes() as $attribute) { + $arrData[$attribute->getColName()] = null; + } + } + $this->arrData = $arrData; $this->metaModel = $objMetaModel; }