I have a class wich looks like this (simplified):
class Tour extends DataObject implements PermissionProvider {
static $default_sort = 'StartDatum ASC';
static $db = array(
'TourName' => 'Varchar(255)',
'Typ' => "Enum('Kurs, Skitour, Bergtour, Hochtour, Klettertour, Wanderung, Velotour, Anderes', 'Anderes') ",
'Beschreibung' => 'Text',
'StartDatum' => 'Date',
'EndDatum' => 'Date',
'Tourenbericht' => 'HTMLText'
);
static $summary_fields = array(
'Datum' => 'Datum',
'TourName' => 'Tour',
'Typ' => 'Art',
'TourenberichtSummary' => 'Tourenbericht'
);
public function getDatum() {
$startDatum = new SwissDate(); // SwissDate overrides the RangeString function of Date
$startDatum->setValue($this->StartDatum);
$endDatum = new SwissDate();
$endDatum->setValue($this->EndDatum);
if($startDatum->Format('d.m.Y') == $endDatum->Format('d.m.Y')) {
return $startDatum->Format('d.m.Y');
}
return $startDatum->RangeString($endDatum);
}
public function getTourenberichtSummary() {
if($this->Tourenbericht) {
return '<img src="cms/images/alert-good.gif" />';
}
return '';
}
}
and a ModelAdmin for this which looks like this:
class TourAdmin extends ModelAdmin {
static $managed_models = array(
'Tour'
);
static $url_segment = 'touren';
static $menu_title = 'Touren';
}
but when i call the AdminInterface (localhost/admin/touren) iget this error:
[User Error] Uncaught Exception: Unable to traverse to related object field [Datum] on [Tour]
How do I use custom getters in ModelAdmin? At all other places this works just fine with the custom getters!