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   14078 Views

Avatar
Blackdog

Community Member, 156 Posts

31 January 2011 at 11:27pm

Edited: 31/01/2011 11:27pm

@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

Community Member, 11 Posts

31 January 2011 at 11:35pm

@Blackdog

Thanks for the hint.

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

Avatar
Blackdog

Community Member, 156 Posts

31 January 2011 at 11:58pm

Have you tried the following?

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

Avatar
idefix

Community Member, 11 Posts

1 February 2011 at 12:20am

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

Avatar
idefix

Community Member, 11 Posts

1 February 2011 at 12:23am

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

Community Member, 11 Posts

1 February 2011 at 12:24am

Is there any special way to format the date?

Avatar
mirkosassetti

Community Member, 20 Posts

17 February 2011 at 12:04am

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

Avatar
idefix

Community Member, 11 Posts

17 February 2011 at 8:09am

Edited: 15/03/2011 1:30am

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.