Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402]

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: 303 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.

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

_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

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

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.

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