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.

Customising the CMS /

Add Date Picker Field to Reports


Reply


2 Posts   663 Views

Avatar
radialgraphics

Community Member, 1 Post

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 [url=http://www.silverstripe.org/customising-the-cms/show/15602]post[/url] 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