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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Feature Requests


Reply

75 Posts   13698 Views

Avatar
Blackdog

31 January 2011 at 11:27pm (Last edited: 31 January 2011 11:27pm), Community Member, 156 Posts

@idefix.

Try this

$dateField = new DateField('Date');
$dateField->setConfig('showcalendar', true);
$dateField->setValue('PRESET_VALUE_IN_HERE');
$fields->addFieldToTab("Root.Content.Main", $dateField);

Avatar
idefix

31 January 2011 at 11:35pm Community Member, 11 Posts

@Blackdog

Thanks for the hint.

The preset value appears, but not the calendar!
But I want both.

Avatar
Blackdog

31 January 2011 at 11:58pm Community Member, 156 Posts

Have you tried the following?

new DateField('Date','Date','PRESET IN HERE');

Avatar
idefix

1 February 2011 at 12:20am Community Member, 11 Posts

Sorry, Calendar is now here, but no more the preset value!

Avatar
idefix

1 February 2011 at 12:23am Community Member, 11 Posts

Hi Blackdog,

This:

$ende = new DateField('Ende','Ende', '31/10/2010');
$ende->setConfig('showcalendar', true);
$fields->addFieldToTab("Root.News", $ende);

is the same as before, Calendar yes, Preset value is not visible and not even preselected in the calendar.

Avatar
idefix

1 February 2011 at 12:24am Community Member, 11 Posts

Is there any special way to format the date?

Avatar
mirkosassetti

17 February 2011 at 12:04am Community Member, 20 Posts

See http://www.silverstripe.org/dataobjectmanager-module-forum/show/15755#post298748

Avatar
idefix

17 February 2011 at 8:09am (Last edited: 15 March 2011 1:30am), Community Member, 11 Posts

Hi,
I solved my problem:

to prefill a datefield you have to set the DataObject-variable.
e.g.:

function getCMSFields() {
$fields = parent::getCMSFields();
$today = date("d/m/Y");
$fldCalendar = new DatePickerField("Start","Start-Datum",$value="$today"); // $value="$today" doesn't take effect but in TextField it DOES!
if (!$this->Start) $this->Start = $heute; // THIS is the important thing! to show in the new created DataObject Form a prefilling value
$fields->addFieldToTab("Root.Content", $fldCalendar);
return $fields;
}

Maybe somebody can save some time with this.