Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / lib / form / selectyesno.php
blob1f4df1c6eaa263967cabfe2655f98980ae077708
1 <?php
2 global $CFG;
3 require_once "$CFG->libdir/form/select.php";
5 /**
6 * HTML class for a simple yes/ no drop down element
8 * @author Jamie Pratt
9 * @access public
11 class MoodleQuickForm_selectyesno extends MoodleQuickForm_select{
14 /**
15 * Class constructor
17 * @param string Select name attribute
18 * @param mixed Label(s) for the select
19 * @param mixed Either a typical HTML attribute string or an associative array
20 * @param mixed $options ignored
21 * @access public
22 * @return void
24 function MoodleQuickForm_selectyesno($elementName=null, $elementLabel=null, $attributes=null, $options=null)
26 HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes, null);
27 $this->_type = 'selectyesno';
29 } //end constructor
31 /**
32 * Called by HTML_QuickForm whenever form event is made on this element
34 * @param string $event Name of event
35 * @param mixed $arg event arguments
36 * @param object $caller calling object
37 * @since 1.0
38 * @access public
39 * @return mixed
41 function onQuickFormEvent($event, $arg, &$caller)
43 switch ($event) {
44 case 'createElement':
45 $choices=array();
46 $choices[0] = get_string('no');
47 $choices[1] = get_string('yes');
48 $this->load($choices);
49 break;
51 return parent::onQuickFormEvent($event, $arg, $caller);