diff --git a/src/admin/common/abstract/model.php b/src/admin/common/abstract/model.php index 9a1561f..41829ef 100644 --- a/src/admin/common/abstract/model.php +++ b/src/admin/common/abstract/model.php @@ -117,6 +117,9 @@ abstract class AbstractCommonClubsModel if($v['type'] !== 'ref') continue; + if(is_null($vals[$k])) + continue; + $vals[$k] = $vals[$k]->getId(); } @@ -133,6 +136,9 @@ abstract class AbstractCommonClubsModel if(empty($v['ref'])) throw new Exception('External reference of unknown class found.'); + if(empty($vals[$k])) + continue; + $vals[$k] = $this->loadExternalReferenceAsObject($v['ref'], $vals[$k]); } @@ -304,6 +310,7 @@ abstract class AbstractCommonClubsModel $q->where("id = {$this->id}"); } + // FIXME Add additional filter to remove associations of the object public function delete() { $db = Factory::getDbo(); diff --git a/src/admin/common/abstract/model/factory.php b/src/admin/common/abstract/model/factory.php index 491799c..bb60ee9 100644 --- a/src/admin/common/abstract/model/factory.php +++ b/src/admin/common/abstract/model/factory.php @@ -30,6 +30,7 @@ abstract class AbstractCommonClubsModelFactory * - int * - float * - ref + * - optional: boolean, if true, the field can be NULL * - ref: (only with type='ref') The name of the class that is referenced */ public abstract function getAttributes(); diff --git a/src/admin/common/models/factory/place.php b/src/admin/common/models/factory/place.php index a08046e..c8f1bd8 100644 --- a/src/admin/common/models/factory/place.php +++ b/src/admin/common/models/factory/place.php @@ -9,7 +9,8 @@ class CommonClubsModelFactoryPlace extends AbstractCommonClubsModelFactory { return array( 'name'=>array(), - 'club'=>array('col'=>'clubid', 'type'=>'ref', 'ref'=>'CommonClubsModelClub') + 'club'=>array('col'=>'clubid', 'type'=>'ref', 'ref'=>'CommonClubsModelClub'), + 'area'=>array('type'=>'int', 'optional'=>true) ); }