public function test_select_yesno() { $select = html_select::make_yes_no('question', 1); $html = $this->renderer->select($select); $this->assert(new ContainsTagWithAttributes('select', array('class' => 'menuquestion select', 'name' => 'question', 'id' => 'menuquestion')), $html); $this->assert(new ContainsTagWithContents('option', get_string('choosedots')), $html); $this->assert(new ContainsTagWithContents('option', get_string('yes')), $html); $this->assert(new ContainsTagWithContents('option', get_string('no')), $html); $this->assert(new ContainsTagWithAttributes('option', array('value' => '1', 'selected' => 'selected')), $html); }
/** * Choose value 0 or 1 from a menu with options 'No' and 'Yes'. * Other options like choose_from_menu. * * @deprecated since Moodle 2.0 * * Calls {@link choose_from_menu()} with preset arguments * @see choose_from_menu() * * @param string $name the name of this form control, as in <select name="..." ... * @param string $selected the option to select initially, default none. * @param string $script if not '', then this is added to the <select> element as an onchange handler. * @param boolean $return Whether this function should return a string or output it (defaults to false) * @param boolean $disabled (defaults to false) * @param int $tabindex * @return string|void If $return=true returns string, else echo's and returns void */ function choose_from_menu_yesno($name, $selected, $script = '', $return = false, $disabled = false, $tabindex = 0) { debugging('choose_from_menu_yesno() has been deprecated. Please change your code to use $OUTPUT->select($select).'); global $OUTPUT; if ($script) { debugging('The $script parameter has been deprecated. You must use component_actions instead', DEBUG_DEVELOPER); } $select = html_select::make_yes_no($name, $selected); $select->disabled = $disabled; $select->tabindex = $tabindex; $output = $OUTPUT->select($select); if ($return) { return $output; } else { echo $output; } }