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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

[solved] DateFormat in HasOneComplexTableField


Go to End


11 Posts   2363 Views

Avatar
Devlin

Community Member, 344 Posts

18 August 2011 at 2:35am

Edited: 18/08/2011 2:38am

Hi there. Just add the following code to your HasOneComplexTableField.

$tablefield = new HasOneComplexTableField();
$tablefield->fieldCasting = array(
'Date' => array("Date->Format","d-m-Y"),
);

You can use array("Date->FormatI18N","%d. %B %Y") for a even nicer date too.

http://api.silverstripe.org/2.4/forms/fields-relational/ComplexTableField.html
http://api.silverstripe.org/2.4/sapphire/model/Date.html#methodFormat
http://api.silverstripe.org/2.4/sapphire/model/Date.html#methodFormatI18N

Avatar
quanto

Community Member, 91 Posts

18 August 2011 at 2:42am

Thanks Devlin (and martimiz), It works!

Avatar
martimiz

Forum Moderator, 1391 Posts

18 August 2011 at 3:12am

@Devlin - nice!

Go to Top