$form = new html_form();
$form->url = new moodle_url($link, $options);
$form->button = new html_button();
- $form->button->label = $label;
+ $form->button->text = $label;
$form->button->disabled = $disabled;
$form->button->title = $tooltip;
$form->method = $method;
$formcontinue = new html_form();
$formcontinue->url = new moodle_url($linkyes, $optionsyes);
- $formcontinue->button->label = get_string('yes');
+ $formcontinue->button->text = get_string('yes');
$formcontinue->method = $methodyes;
$formcancel = new html_form();
$formcancel->url = new moodle_url($linkno, $optionsno);
- $formcancel->button->label = get_string('no');
+ $formcancel->button->text = get_string('no');
$formcancel->method = $methodno;
echo $OUTPUT->confirm($message, $formcontinue, $formcancel);
public function test_button() {
global $CFG;
$originalform = new html_form();
- $originalform->button->label = 'Click Here';
+ $originalform->button->text = 'Click Here';
$originalform->url = '/index.php';
$form = clone($originalform);
$this->expectException();
$html = $this->renderer->link($link->url->out());
}
-
+
/**
- * NOTE: consider the degree of detail in which we test HTML output, because
+ * NOTE: consider the degree of detail in which we test HTML output, because
* the unit tests may be run under a different theme, with different HTML
* renderers. Maybe we should limit unit tests to standardwhite.
*/
$this->assert(new ContainsTagWithAttributes('input', array('type' => 'hidden', 'name' => 'cancel', 'value' => 1)), $html);
$this->assert(new ContainsTagWithAttributes('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())), $html);
$this->assert(new ContainsTagWithAttributes('input', array('type' => 'submit', 'value' => get_string('no'), 'class' => 'singlebutton')), $html);
-
+
// Use html_forms with default values, should produce exactly the same output as above
$formcontinue = new html_form();
$formcancel = new html_form();
$this->assert(new ContainsTagWithAttributes('input', array('type' => 'hidden', 'name' => 'cancel', 'value' => 1)), $html);
$this->assert(new ContainsTagWithAttributes('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())), $html);
$this->assert(new ContainsTagWithAttributes('input', array('type' => 'submit', 'value' => get_string('no'), 'class' => 'singlebutton')), $html);
-
+
// Give the buttons some different labels
$formcontinue = new html_form();
$formcancel = new html_form();
$formcontinue->url = new moodle_url($continueurl);
$formcancel->url = new moodle_url($cancelurl);
- $formcontinue->button->label = 'Continue anyway';
- $formcancel->button->label = 'Wow OK, I get it, backing out!';
+ $formcontinue->button->text = 'Continue anyway';
+ $formcancel->button->text = 'Wow OK, I get it, backing out!';
$html = $this->renderer->confirm($message, $formcontinue, $formcancel);
$this->assert(new ContainsTagWithAttributes('form', array('method' => 'post', 'action' => 'http://www.test.com/index.php')), $html);
$this->assert(new ContainsTagWithAttributes('input', array('type' => 'hidden', 'name' => 'continue', 'value' => 1)), $html);
$this->assert(new ContainsTagWithAttributes('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())), $html);
- $this->assert(new ContainsTagWithAttributes('input', array('type' => 'submit', 'value' => $formcontinue->button->label, 'class' => 'singlebutton')), $html);
+ $this->assert(new ContainsTagWithAttributes('input', array('type' => 'submit', 'value' => $formcontinue->button->text, 'class' => 'singlebutton')), $html);
$this->assert(new ContainsTagWithAttributes('input', array('type' => 'hidden', 'name' => 'cancel', 'value' => 1)), $html);
$this->assert(new ContainsTagWithAttributes('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())), $html);
- $this->assert(new ContainsTagWithAttributes('input', array('type' => 'submit', 'value' => $formcancel->button->label, 'class' => 'singlebutton')), $html);
-
+ $this->assert(new ContainsTagWithAttributes('input', array('type' => 'submit', 'value' => $formcancel->button->text, 'class' => 'singlebutton')), $html);
+
// Change the method and add extra variables
$formcontinue = new html_form();
$formcancel = new html_form();