I have a date field which the users of the system can edit, but there are limitations on what they may be able to select. Right now it is simple and just limited to "n" number of days into the future. But I could see it getting more sophisticated with only allowing weekdays, etc. I can write the select elements manually, but I'm curious if there are any helpers that have started tackling this.
A:
There is nothing that I have found. But this should be simple enough to create:
// populate with the weekdays you want (0=Sunday, 1=Monday, etc.)
$weekdays = array(1,2,3,4,5);
$dates = array();
$today = strtotime(date("Y-m-d"));
$end_date = strtotime("+6 months");
while($today < $end_date) {
$weekday = date("w", $today);
if (in_array($weekday, $weekdays)) {
array_push($dates, date("Y-m-d", $today));
}
$today += 86400;
}
$this->set('dates', $dates)
Then in the view:
$this->Form->input('my_date', array('type' => 'select', 'options' => $dates));
cdburgess
2010-08-26 23:30:06