MDL-20204 converting yes_no selects
This commit is contained in:
@@ -8,7 +8,6 @@ $servercount = 0;
|
||||
if (is_array($mnethosts)) {
|
||||
$servercount = count(array_keys($mnethosts));
|
||||
}
|
||||
$select = html_select::make_yes_no('enrol_mnet_allow_allcourses', $frm->enrol_mnet_allow_allcourses);
|
||||
|
||||
?>
|
||||
<table cellspacing="0" cellpadding="5" border="0" class="boxaligncenter">
|
||||
@@ -20,7 +19,7 @@ $select = html_select::make_yes_no('enrol_mnet_allow_allcourses', $frm->enrol_mn
|
||||
<tr valign="top">
|
||||
<td align="right">allow_allcourses:</td>
|
||||
<td>
|
||||
<?php echo $OUTPUT->select($select); ?>
|
||||
<?php echo html_writer:.select_yes_no('enrol_mnet_allow_allcourses', $frm->enrol_mnet_allow_allcourses); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("allow_allcourses", "enrol_mnet") ?>
|
||||
|
||||
@@ -3113,10 +3113,7 @@ function choose_from_menu_yesno($name, $selected, $script = '', $return = false,
|
||||
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);
|
||||
$output = html_writer::select_yes_no($name, $selected, array('disabled'=>($disabled ? 'disabled' : null), 'tabindex'=>$tabindex));
|
||||
|
||||
if ($return) {
|
||||
return $output;
|
||||
|
||||
+13
-11
@@ -689,6 +689,18 @@ class html_writer {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a simple select yes/no form field
|
||||
* @param string $name name of select element
|
||||
* @param bool $selected
|
||||
* @param array $attributes - html select element attributes
|
||||
* @return string HRML fragment
|
||||
*/
|
||||
public function select_yes_no($name, $selected=true, array $attributes = null) {
|
||||
$options = array('1'=>get_string('yes'), '0'=>get_string('no'));
|
||||
return self::select($options, $name, $selected, null, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a simple select form field
|
||||
* @param array $options associative array value=>label ex.:
|
||||
@@ -700,7 +712,7 @@ class html_writer {
|
||||
* @param string|array $selected value or arary of values depending on multiple attribute
|
||||
* @param array|bool $nothing, add nothing selected option, or false of not added
|
||||
* @param array $attributes - html select element attributes
|
||||
* @return string HRML fragment
|
||||
* @return string HTML fragment
|
||||
*/
|
||||
public static function select(array $options, $name, $selected = '', $nothing = array(''=>'choosedots'), array $attributes = null) {
|
||||
$attributes = (array)$attributes;
|
||||
@@ -1362,16 +1374,6 @@ class html_select extends labelled_html_component {
|
||||
return $menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a shortcut for making a yes/no select menu.
|
||||
* @param string $name used to initialise {@link $name}.
|
||||
* @param string $selected used to initialise {@link $selected}.
|
||||
* @return html_select A menu initialised with yes/no options.
|
||||
*/
|
||||
public static function make_yes_no($name, $selected) {
|
||||
return self::make(array(0 => get_string('no'), 1 => get_string('yes')), $name, $selected);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a shortcut for making an hour selector menu.
|
||||
* @param string $type The type of selector (years, months, days, hours, minutes)
|
||||
|
||||
@@ -574,16 +574,6 @@ class core_renderer_test extends UnitTestCase {
|
||||
$this->assert(new ContainsTagWithContents('label', 'Cool menu'), $html);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public function test_error_text() {
|
||||
$html = $this->renderer->error_text('message');
|
||||
$this->assert(new ContainsTagWithContents('span', 'message'), $html);
|
||||
|
||||
Reference in New Issue
Block a user