Duration element.
More...
|
| __construct ($elementName=null, $elementLabel=null, $options=[], $attributes=null) |
| constructor
|
|
| _createElements () |
| Override of standard quickforms method to create this element.
|
|
| accept (&$renderer, $required=false, $error=null) |
| Accepts a renderer.
|
|
| createFormElement () |
| Creates an element to add to the group Expects the same arguments as MoodleQuickForm::createElement()
|
|
| export_for_template (renderer_base $output) |
|
| exportValue (&$submitValues, $assoc=false) |
| Output a timestamp.
|
|
| get_units () |
| Returns time associative array of unit length.
|
|
| getAttributesForFormElement () |
| Return attributes suitable for passing to {.
|
|
| getElementTemplateType () |
| Returns element template, nodisplay/static/fieldset.
|
|
string | getHelpButton () |
| template type, would cause problems with client side validation so will leave for now
|
|
| MoodleQuickForm_duration ($elementName=null, $elementLabel=null, $options=[], $attributes=null) |
| Old syntax of class constructor.
|
|
| MoodleQuickForm_group ($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName=true) |
| Old syntax of class constructor.
|
|
| onQuickFormEvent ($event, $arg, &$caller) |
| Called by HTML_QuickForm whenever form event is made on this element.
|
|
| seconds_to_unit ($seconds) |
| Converts seconds to the best possible time unit.
|
|
| setElements ($elements) |
| Sets the grouped elements and hides label.
|
|
| setHiddenLabel ($hiddenLabel) |
| Sets label to be hidden.
|
|
| setMoodleForm ($mform) |
| Stores the form this element was added to This object is later used by MoodleQuickForm_group::createElement().
|
|
| toHtml () |
| Returns HTML for advchecbox form element.
|
|
| validateSubmitValue ($values) |
| Calls the validateSubmitValue function for the containing elements and returns an error string as soon as it finds one.
|
|
|
string | $_helpbutton ='' |
| html for help button, if empty then no help
|
|
|
bool | $_hiddenLabel = false |
| if true label will be hidden.
|
|
MoodleQuickForm | $_mform = null |
|
array | $_options = ['optional' => false, 'defaultunit' => MINSECS, 'allownegative' => false] |
| Control the field names for form elements optional => if true, show a checkbox beside the element to turn it on (or off) defaultunit => which unit is default when the form is blank (default Minutes).
|
|
| $_renderedfromtemplate = false |
|
Duration element.
HTML class for a length of time. For example, 30 minutes of 4 days. The values returned to PHP is the duration in seconds (an int rounded to the nearest second).
By default, only durations >= 0 can be input. If you want to allow negative durations set the option allownegative.
- Copyright
- 2009 Tim Hunt
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ __construct()
MoodleQuickForm_duration::__construct |
( |
| $elementName = null, |
|
|
| $elementLabel = null, |
|
|
| $options = [], |
|
|
| $attributes = null ) |
constructor
- Parameters
-
?string | $elementName | Element's name |
mixed | $elementLabel | Label(s) for an element |
array | $options | Options to control the element's display. Recognised values are 'optional' => true/false - whether to display an 'enabled' checkbox next to the element. 'defaultunit' => 1|MINSECS|HOURSECS|DAYSECS|WEEKSECS - the default unit to display when the time is blank. If not specified, minutes is used. 'units' => array containing some or all of 1, MINSECS, HOURSECS, DAYSECS and WEEKSECS which unit choices to offer. 'allownegative' => true/false - are durations < 0 allowed? (default false) |
mixed | $attributes | Either a typical HTML attribute string or an associative array |
◆ accept()
MoodleQuickForm_duration::accept |
( |
& | $renderer, |
|
|
| $required = false, |
|
|
| $error = null ) |
Accepts a renderer.
- Parameters
-
HTML_QuickForm_Renderer | $renderer | An HTML_QuickForm_Renderer object |
bool | $required | Whether a group is required |
?string | $error | An error message associated with a group |
Reimplemented from MoodleQuickForm_group.
◆ export_for_template()
MoodleQuickForm_group::export_for_template |
( |
renderer_base | $output | ) |
|
|
inherited |
◆ exportValue()
MoodleQuickForm_duration::exportValue |
( |
& | $submitValues, |
|
|
| $assoc = false ) |
Output a timestamp.
Give it the name of the group. Override of standard quickforms method.
- Parameters
-
array | $submitValues | |
bool | $assoc | whether to return the value as associative array |
- Return values
-
array | field name => value. The value is the time interval in seconds. |
◆ get_units()
MoodleQuickForm_duration::get_units |
( |
| ) |
|
Returns time associative array of unit length.
- Return values
-
array | unit length in seconds => string unit name. |
◆ get_units_used()
MoodleQuickForm_duration::get_units_used |
( |
| ) |
|
|
protected |
Get the units to be used for this field.
The ones specified in the options passed to the constructor, or all by default.
- Return values
-
array | number of seconds => lang string. |
◆ getAttributesForFormElement()
MoodleQuickForm_group::getAttributesForFormElement |
( |
| ) |
|
|
inherited |
Return attributes suitable for passing to {.
- See also
- createFormElement}, comprised of all group attributes without ID in order to ensure uniqueness of that value within the group
- Return values
-
◆ getElementTemplateType()
MoodleQuickForm_group::getElementTemplateType |
( |
| ) |
|
|
inherited |
Returns element template, nodisplay/static/fieldset.
- Return values
-
◆ getHelpButton()
string MoodleQuickForm_group::getHelpButton |
( |
| ) |
|
|
inherited |
template type, would cause problems with client side validation so will leave for now
set html for help button
◆ MoodleQuickForm_duration()
MoodleQuickForm_duration::MoodleQuickForm_duration |
( |
| $elementName = null, |
|
|
| $elementLabel = null, |
|
|
| $options = [], |
|
|
| $attributes = null ) |
◆ MoodleQuickForm_group()
MoodleQuickForm_group::MoodleQuickForm_group |
( |
| $elementName = null, |
|
|
| $elementLabel = null, |
|
|
| $elements = null, |
|
|
| $separator = null, |
|
|
| $appendName = true ) |
|
inherited |
◆ onQuickFormEvent()
MoodleQuickForm_duration::onQuickFormEvent |
( |
| $event, |
|
|
| $arg, |
|
|
& | $caller ) |
Called by HTML_QuickForm whenever form event is made on this element.
- Parameters
-
string | $event | Name of event |
mixed | $arg | event arguments |
MoodleQuickForm | $caller | calling object |
- Return values
-
Reimplemented from MoodleQuickForm_group.
◆ seconds_to_unit()
MoodleQuickForm_duration::seconds_to_unit |
( |
| $seconds | ) |
|
Converts seconds to the best possible time unit.
for example 1800 -> [30, MINSECS] = 30 minutes.
- Parameters
-
int | $seconds | an amout of time in seconds. |
- Return values
-
array | associative array ($number => $unit) |
◆ setElements()
MoodleQuickForm_group::setElements |
( |
| $elements | ) |
|
|
inherited |
Sets the grouped elements and hides label.
- Parameters
-
◆ setHiddenLabel()
MoodleQuickForm_group::setHiddenLabel |
( |
| $hiddenLabel | ) |
|
|
inherited |
Sets label to be hidden.
- Parameters
-
bool | $hiddenLabel | sets if label should be hidden |
◆ setMoodleForm()
MoodleQuickForm_group::setMoodleForm |
( |
| $mform | ) |
|
|
inherited |
◆ toHtml()
MoodleQuickForm_duration::toHtml |
( |
| ) |
|
Returns HTML for advchecbox form element.
- Return values
-
◆ validateSubmitValue()
MoodleQuickForm_duration::validateSubmitValue |
( |
| $values | ) |
|
Calls the validateSubmitValue function for the containing elements and returns an error string as soon as it finds one.
- Parameters
-
array | $values | Values of the containing elements. |
- Return values
-
string|null | Validation error message or null. |
Reimplemented from MoodleQuickForm_group.
◆ $_options
array MoodleQuickForm_duration::$_options = ['optional' => false, 'defaultunit' => MINSECS, 'allownegative' => false] |
|
protected |
Control the field names for form elements optional => if true, show a checkbox beside the element to turn it on (or off) defaultunit => which unit is default when the form is blank (default Minutes).
allownegative => are durations < 0 allowed? (default false)
The documentation for this class was generated from the following file: