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

DateField in SS 2.4.1

Go to End

4 Posts   2485 Views


Community Member, 267 Posts

17 August 2010 at 10:27pm


It used to be so easy in SS 2.3.7. Now it's not working in SS 2.4.1

When entering a date in the CMS, like 08/16/2010

It is - after save - converted to: Aug 16, 2010

But when you edit the page, and click save again you get the error:
'validation failed'

This is because the date is as text, because when i enter the date in numbers again, it will save.

How do i fix this/ Keep the date in numbers??


the code:


Community Member, 30 Posts

17 August 2010 at 10:45pm

Edited: 17/08/2010 10:52pm


Community Member, 267 Posts

17 August 2010 at 11:09pm

Complete code

 * Defines the ArticlePage page type
class ArticlePageextends Page {
   static $db = array(
      'Date' => 'Date',
      'Author' => 'Text'

   static $has_one = array(
	function getCMSFields() {
		$fields = parent::getCMSFields();
		$DateField = new Datefield('Date','Date');
		$DateField->setConfig('showcalendar', true);
		$DateField->setConfig('dateformat', 'dd-MM-YYYY'); 

		$fields->addFieldToTab('Root.Content.Main', $DateField, 'Content');	
		$fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');
		return $fields;

class ArticlePage_Controller extends Page_Controller {


Community Member, 50 Posts

17 February 2011 at 10:33pm

Thank you, this was very helpful