Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

Duration form element Contains class to create length of time for element.

Copyright: 2009 Tim Hunt
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 306 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

MoodleQuickForm_duration:: (2 methods):
  __construct()
  MoodleQuickForm_duration()

name:: (8 methods):
  get_units()
  get_units_used()
  seconds_to_unit()
  _createElements()
  onQuickFormEvent()
  toHtml()
  accept()
  exportValue()


Class: MoodleQuickForm_duration  - X-Ref

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).

__construct($elementName = null, $elementLabel = null,$options = [], $attributes = null)   X-Ref
constructor

param: ?string $elementName Element's name
param: mixed $elementLabel Label(s) for an element
param: array $options Options to control the element's display. Recognised values are
param: mixed $attributes Either a typical HTML attribute string or an associative array

MoodleQuickForm_duration($elementName = null, $elementLabel = null,$options = [], $attributes = null)   X-Ref
Old syntax of class constructor. Deprecated in PHP7.


Class: name  - X-Ref

get_units()   X-Ref
Returns time associative array of unit length.

return: array unit length in seconds => string unit name.

get_units_used()   X-Ref
Get the units to be used for this field.

The ones specified in the options passed to the constructor, or all by default.

return: array number of seconds => lang string.

seconds_to_unit($seconds)   X-Ref
Converts seconds to the best possible time unit. for example
1800 -> [30, MINSECS] = 30 minutes.

return: array associative array ($number => $unit)
param: int $seconds an amout of time in seconds.

_createElements()   X-Ref
Override of standard quickforms method to create this element.


onQuickFormEvent($event, $arg, &$caller)   X-Ref
Called by HTML_QuickForm whenever form event is made on this element

return: bool
param: string $event Name of event
param: mixed $arg event arguments
param: MoodleQuickForm $caller calling object

toHtml()   X-Ref
Returns HTML for advchecbox form element.

return: string

accept(&$renderer, $required = false, $error = null)   X-Ref
Accepts a renderer

param: HTML_QuickForm_Renderer $renderer An HTML_QuickForm_Renderer object
param: bool $required Whether a group is required
param: ?string $error An error message associated with a group

exportValue(&$submitValues, $assoc = false)   X-Ref
Output a timestamp. Give it the name of the group.
Override of standard quickforms method.

return: array field name => value. The value is the time interval in seconds.
param: array $submitValues
param: bool  $assoc  whether to return the value as associative array