Class: Zebra_Form_Time
source file: /includes/Time.php
Class Overview
XSS_Clean
|
--Zebra_Form_Control
|
--Zebra_Form_Time
Class for time picker controls.
Author(s):
Copyright:
- (c) 2006 - 2013 Stefan Gabos
Class methods
constructor __construct()
void
__construct (
string
$id
,
[
string
$default
= '']
,
[
array
$attributes
= '']
)
Adds a time picker control to the form.
Do not instantiate this class directly! Use the add() method instead!
The output of this control will be one, two, three or four select controls for hour, minutes, seconds and AM/PM respectively, according to the given format as set by the $attributes argument.
Note that even though there will be more select boxes, the submitted values will be available as a single merged value (in the form of hh:mm:ss AM/PM, depending on the format), with the name as given by the id argument.
// create a new form
// add a time picker control for hour and minutes
$obj =
$form->add('time', 'my_time', date('H:i'), array('format' =>
'hm'));
// don't forget to always call this method before rendering the form
if ($form->validate()) {
// note that even though there will be more select boxes, the submitted
// values will be available as a single merged value (in the form of
// mm:mm:ss AM/PM, depending on the format), with the name as given by
// the "id" argument:
echo $_POST['my_time'];
}
// output the form using an automatically generated template
$form->render();
Parameters:
| string |
$id |
Unique name to identify the control in the form. The control's name attribute will be the same as the id attribute! This is the name to be used when referring to the control's value in the POST/GET superglobals, after the form is submitted. This is also the name of the variable to be used in custom template files, in order to display the control. // in a template file, in order to print the generated HTML
// for a control named "my_time", one would use:
echo $my_time;
|
| string |
$default |
(Optional) String representing the default time to be shown. Must be set according to the format of the time, as specified in $attributes. For example, for a time format of "hm", one would set the default time in the form of "hh:mm" while for a time format of "hms", one would set the time in the form of "hh:mm:ss". Default is current system time. |
| array |
$attributes |
(Optional) An array of user specified attributes valid for an time picker control (format, hours, minutes, seconds, am/pm). Must be specified as an associative array, in the form of attribute => value. Available attributes are: - format - format of time; a string containing one, or a combination of the four
allowed characters: "h" (hours), "m" (minutes) and "s" (seconds) and "g" for
using 12-hours format instead of the default 23-hours format; (i.e. setting the
format to "hm" would allow the selection of hours and minutes, setting the
format to "hms" would allow the selection of hours, minutes and seconds, and
setting the format to "hmg" would allow the selection of hours and minutes
using the 12-hours format instead of the 24-hours format)
- hours - an array of selectable hours (i.e. array(10, 11, 12))
- minutes - an array of selectable minutes (i.e. array(15, 30, 45))
- seconds - an array of selectable seconds
See set_attributes() on how to set attributes, other than through the constructor. |
Top
method toHTML()
string
toHTML (
)
Generates and returns the control's HTML code.
This method is automatically called by the render() method!
Tags:
| return: |
The control's HTML code |
Top