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.

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   2525 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