QF date suggestion
| From: | Jeroen Houben | Date: | Thu, 30 Oct 2003 10:28:41 +0000 |
| Subject: | QF date suggestion | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-23137@lists.php.net to get a copy of this message | ||
Hi,
I have a really simple option to add the the QF date element. Perhaps you can incorporate it in the next version.
It allows you to define intervals for the minute select box. Can be very useful, for instance in some scheduling application where you want the user to only be able to select certain minutes. Like 5, 10, 15, 20 ... etc.
In the $this->_options array I added (1 is defaut):
'minuteInterval' => 1
setting it to 5 would generate this selectbox:
5
10
15
...
55
in the _createElements() method I added on param:
case 'i':
$options = $this->_createOptionList(0, 59, $this->_options['minuteInterval']);
break;
so the _createOptionList() method will look like this.
/**
* Creates an option list containing the numbers from the start number to the end, inclusive
*
* @param int The start number * @param int The end number * @param int interval. Allows you to limit the number of possible values* @access private * @return array An array of numeric options. */ function _createOptionList($start, $end, $interval = 1) {
for ($i = $start, $options = array(); $i <= $end; $i = $i + $interval) {
$options[$i] = sprintf('%02d', $i);
}
return $options;
}
This could easily be implemented for seconds or any part of the date really, but minutes and perhaps hours are the only ones I see a real use for.
I was also thinking of being able to directly pass an array as $options. That way you could select only a few months users can chose from.
for montsh for instance:
case 'm':
$options = array(4,5,6); // only april, may and june can be selected
break;
Let me know if you find this useful.
Regards,
Jeroen