I am having some issues with the Options array for the DateRangePicker package.
My ideal drop down menu would give the user a list of 3 or 4 ranges, with no custom input options. The range would default to either the last 7 days, or last 30 days (Not sure which one yet). I think all the issues are related some how, just not exactly sure.
The first thing I've noticed is that if I don't have the range "today" shown, the calendar shows up regardless of the showCustomRangeLabel option. After reading a little more, I realized that if the text field range does not match a pre-defined range, the text field will show up (so adding Today fixes that issue)
So, now I am trying to set the startDate and endDate using the option array, so that it matches one of the ranges and it won't set the range, and only defaults too today. Reading the date range picker website, it says that if I specify a startDate, it needs to match the locale settings, which appears it does - but I am still not getting any results.
<?php
$dateFormat = "m/d/Y";
$defaultEndDate = date($dateFormat);
$defaultStartDate = date($dateFormat, strtotime("-1 months"));
DateRangePicker::create(array(
"name"=>"dateRange",
"locale"=>"MM/DD/YYYY",
"ranges" =>array(
"Today"=>DateRangePicker::today(),
"Last 7 days"=>DateRangePicker::last7days(),
"Last 30 days"=>DateRangePicker::last30days(),
"This month"=>DateRangePicker::thisMonth(),
"Last month"=>DateRangePicker::lastMonth()
),
"options"=>array(
"showCustomRangeLabel"=>false,
"startDate"=>$defaultStartDate,
"endDate"=>$defaultEndDate),
)
);
?>
I read further about using the defaultParamValues() function, so I tried this:
Completed.php:
protected function defaultParamValues()
{
return array(
#"dateRange"=>array(date("M jS Y", strtotime("-30 days")), date("M jS Y")),
"dateRange"=>array('2018-12-25', '2019-01-24')
);
}
Completed.view.php
<?php
DateRangePicker::create(array(
"name"=>"dateRange",
"ranges" =>array(
"Today"=>DateRangePicker::today(),
"Last 7 days"=>DateRangePicker::last7days(),
"Last 30 days"=>DateRangePicker::last30days(),
"This month"=>DateRangePicker::thisMonth(),
"Last month"=>DateRangePicker::lastMonth()
),
)
);
?>
I am still drawing a blank ... and I'm not exactly sure how to make this work?
Suggestions?