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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Format Time.Nice (in the CMS)?


Go to End


4 Posts   1936 Views

Avatar
socks

Community Member, 191 Posts

11 August 2010 at 5:59pm

I have it working on the front-end, but didn't know if it was possible to format a field as Time.Nice within DOM in the CMS.

thanks,
Clint

Avatar
UncleCheese

Forum Moderator, 4102 Posts

12 August 2010 at 1:38am

Just use a custom getter.

public function getNiceTime() {
return $this->obj('YourTimeField')->Nice();
}

and in your summary fields:

'NiceTime' => 'Time'

Avatar
socks

Community Member, 191 Posts

12 August 2010 at 2:06pm

I got that to work, thanks Uncle Cheese.

Is it supposed to work in the Popup as well? I was getting a blank field when going back into the Popup to edit. Not that big of a deal if it doesn't.

thanks again,
Clint

Avatar
UncleCheese

Forum Moderator, 4102 Posts

12 August 2010 at 3:05pm

No, the popup is configured by your getCMSFields() function, not $summary_fields.