Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Date in DOM interface


Reply

3 Posts   876 Views

Avatar
barryvanveen

23 July 2010 at 5:03am Community Member, 11 Posts

Hey all,

I've added a datefield to one of my DOM classes and added some configuration:

class NotulenItem extends DataObject {

static $db = array(
'Vergaderdatum' => 'Date'
);

function getCMSFields_forPopup() {
$dateField = new DateField('Vergaderdatum');
$dateField->setConfig('showcalendar', true);
$dateField->setConfig('dateformat', 'dd/MM/YYYY');
$dateField->setLocale('nl_NL');

$fields = new FieldSet();
$fields->push($dateField);
return $fields;
}

}

This works just about right, when I add a record to my page I see the date in the format I want (dd-mm-yyyy). When I then return to the overview of records that are attached to the page, the date is shown in the default format (yyyy-mm-dd). Is there some way I can influence the format of the Date in the DOM overview?

Cheers!

Barry

Avatar
UncleCheese

23 July 2010 at 5:20am 4085 Posts

Yup.. just write a custom getter..

public function getNiceDate() {
return $this->obj('YourDatefield')->Format('d-m-Y');
}

and then in your fields array, just use "NiceDate" in place of the native date field in the DB.

Avatar
barryvanveen

23 July 2010 at 6:34am Community Member, 11 Posts

Thank you very much for the fast reply, works like a charm :-)