Home » HTML » HTML_QuickForm » Bug #7123
handling of empty dates in HTML_QuickForm_Date
Details
| Request #7123 | handling of empty dates in HTML_QuickForm_Date |
|---|---|
| Submitted | 2006-03-14 23:27 UTC |
| From | demental at free dot fr |
| Assigned | avb |
| Status | Closed |
| Package | HTML_QuickForm |
| PHP Version | Irrelevant |
| OS | any OS |
| Roadmaps | (Not assigned) |
Comments
[2006-03-14 23:27 UTC] demental at free dot fr
Description:
------------
Whenever you have a date field, which is not required in a
form, I did not find a way to handle this.
So the solution can be to extend HTML_QuickForm_Date and
override _createOptionList.
I send the patched version of this method. What do you think
about it ?
Test script:
---------------
function _createOptionList($start, $end, $step = 1)
{
$options = array();
if($start>0) {
$nbdash = strlen(sprintf('%02d', $end));
$options[''] = str_repeat('-',$nbdash);
}
for ($i = $start; $start > $end? $i >= $end: $i <= $end; $i += $step) {
$options[$i] = sprintf('%02d', $i);
}
return $options;
}