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.

General Questions /

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

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

[solved] DateFormat in HasOneComplexTableField


Go to End
Reply


11 Posts   1701 Views

Avatar
Devlin

Community Member, 217 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, 81 Posts

18 August 2011 at 2:42am

Thanks Devlin (and martimiz), It works!

Avatar
martimiz

Forum Moderator, 1132 Posts

18 August 2011 at 3:12am

@Devlin - nice!

Go to Top