Hi,
I have a problem to get cms action of the form. When I have my dataobject (News) listed, I want to difference between edit and create a new one for set date. I mean, when I want to create a new one I want set in the DateField the current date by default, but not when I want to edit or see an existing new that already was saved with other date.
My code:
"News extend to DataObject"
public function getCMSFields()
{
$fields = parent::getCMSFields();
foreach($fields->dataFields() as $f)
{
if (get_class($f) == 'DateField')
{
$datepicker = new DateField('', $f->getName());
$datepicker->setConfig('showcalendar', true);
$datepicker->setConfig('dateformat', 'dd.MM.YYYY');
if($className == 'dNew' && $actionName == 'new') HERE>>> I difference between edit or create
{
$datepicker->setValue(date('d.m.Y'));
}
$fields->replaceField($f->getName(), $datepicker);
}
}
}
I have tried with some ways like getCMSActions, getActionName, getURLParameters and I have looked in the core where I think I can have some hints, but nothing.
The other problem I have is in summary fileds. I want to display dates with german format (d.m.y). The function is call but them I don´t know how to get the value for the List. I get empty cells.
public static $summary_fields = array(
'Title' => 'Titel News',
'getDate' => 'Datum',
'teaser' => 'Teaser'
);
public function getDate()
{
$date = $this->getField('date');
return $date.Nice ;
}
Thanks in advance, regards