Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Date in DOM interface

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 847 Views
  • barryvanveen
    Avatar
    Community Member
    11 Posts

    Date in DOM interface Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Date in DOM interface Link to this post

    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.

  • barryvanveen
    Avatar
    Community Member
    11 Posts

    Re: Date in DOM interface Link to this post

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

    847 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.