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:

Customising the CMS /

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

Add Date Picker Field to Reports


Go to End


2 Posts   1249 Views

Avatar
radialgraphics

Community Member, 2 Posts

22 May 2012 at 5:24pm

Edited: 22/05/2012 5:26pm

Hi there

I am building a custom report in the CMS and cannot get a date picker calendar to appear. The code I am using to insert this on the report is:

$DateField = new Datefield('StartDate','Start Date');
$DateField->setConfig('showcalendar', true); 
$DateField->setConfig('dateformat', 'YYYY-MM-dd');

$params->push($DateField);

I then reference the $params field as follows:

$Records = DataObject::get("Member", "Created between '" . $params['StartDate'] ."' and '" . $params['EndDate'] ."'", "Created DESC", Null);

The field is inserted into the report but just as a text field.

I can get the date picker working using this code if I add the code to a content page and add the field to a tab but not on the Reports page.

Any help with this would be much appreciated.

P.S. this is my first post and I am loving SilverStripe...

Peter

Avatar
Stef87

Community Member, 66 Posts

12 October 2012 at 12:02am

Hi

I was just wondering if you solved this? The following quote from this post is the best I've found but I'm still a little unclear on how to do this.

Note that the jquery popup date picker field won't work in the report admin area if you want to use it. I had to create a custom extension which would include the JS requirements, as well as a little but of custom CSS to make it look OK. However, if you're happy with a text field for date input you'll have no problems.

Thanks