diff --git a/src/admin/common/abstract/model.php b/src/admin/common/abstract/model.php
index e3c4ce8..9a1561f 100644
--- a/src/admin/common/abstract/model.php
+++ b/src/admin/common/abstract/model.php
@@ -141,10 +141,14 @@ abstract class AbstractCommonClubsModel
private function loadExternalReferenceAsObject($className, $value)
{
+ if(is_string($value) && preg_match('/^[0-9]+$/', $value))
+ $value = (int) $value;
+
if(! is_int($value))
throw new Exception('Reference with non-integer value');
- $factory = $this->getFactoryOfClass($className);
+ $factoryName = $this->getFactoryNameOfClass($className);
+ $factory = new $factoryName();
return $factory->loadById($value);
}
@@ -157,7 +161,7 @@ abstract class AbstractCommonClubsModel
* @param string $className
* @return AbstractCommonClubsModelFactory
*/
- private function getFactoryOfClass($className)
+ private function getFactoryNameOfClass($className)
{
if(empty(self::CLASSNAME_MAP[$className]))
{
diff --git a/src/admin/common/models/factory/club.php b/src/admin/common/models/factory/club.php
index 9df0d93..e10dd2c 100644
--- a/src/admin/common/models/factory/club.php
+++ b/src/admin/common/models/factory/club.php
@@ -16,7 +16,7 @@ class CommonClubsModelFactoryClub extends AbstractCommonClubsModelFactory
'iban'=>array(),
'bic'=>array(),
'charitable'=>array('type'=>'int'),
- 'president'=>array('type'=>'int', 'ref'=>'CommonClubsModelUser')
+ 'president'=>array('type'=>'ref', 'ref'=>'CommonClubsModelUser')
);
}
diff --git a/src/admin/common/models/factory/user.php b/src/admin/common/models/factory/user.php
new file mode 100644
index 0000000..7104187
--- /dev/null
+++ b/src/admin/common/models/factory/user.php
@@ -0,0 +1,27 @@
+array(),
+ 'name'=>array()
+ );
+ }
+
+ public function getTableName()
+ {
+ return '#__club_users';
+ }
+
+ public function getClassName()
+ {
+ return 'CommonClubsModelUser';
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/admin/common/models/user.php b/src/admin/common/models/user.php
new file mode 100644
index 0000000..ce8c821
--- /dev/null
+++ b/src/admin/common/models/user.php
@@ -0,0 +1,19 @@
+getValues()['name'];
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/admin/views/test/tmpl/default.php b/src/admin/views/test/tmpl/default.php
index 9c82d19..008dd17 100644
--- a/src/admin/views/test/tmpl/default.php
+++ b/src/admin/views/test/tmpl/default.php
@@ -13,4 +13,4 @@ ClubName: club->getMail(); ?>
ClubName: club->getIban(); ?>
ClubName: club->getBic(); ?>
ClubName: club->isCharitable(); ?>
-ClubName: club->getPresident(); ?>
+ClubName: club->getPresident()->getName(); ?>