When I set the field "Select yesno example" to "Yes"
Then I should see "Test eq hideif"
And "#id_testeqhideif" "css_element" should be visible
+ And I press "Submit"
+ And I should see "Number of submitted form elements: 6"
+ And I should see "[testeqhideif] =>"
Scenario: When 'eq' hideIf conditions are met, the relevant elements are hidden
When I set the field "Select yesno example" to "No"
Then I should not see "Test eq hideif"
And "#id_testeqhideif" "css_element" should not be visible
+ And I press "Submit"
+ And I should see "Number of submitted form elements: 5"
+ And I should not see "[testeqhideif] =>"
Scenario: When 'checked' hideIf conditions are not met, the relevant elements are shown
When I set the field "Checkbox example" to "0"
Then I should see "Test checked hideif"
+ And I should not see "Test not checked hideif"
And "#id_testcheckedhideif" "css_element" should be visible
+ And "#id_testnotcheckedhideif" "css_element" should not be visible
+ And I press "Submit"
+ And I should see "Number of submitted form elements: 5"
+ And I should see "[testcheckedhideif] =>"
+ And I should not see "[testnotcheckedhideif] =>"
Scenario: When 'checked' hideIf conditions are met, the relevant elements are hidden
When I set the field "Checkbox example" to "1"
Then I should not see "Test checked hideif"
+ And I should see "Test not checked hideif"
And "#id_testcheckedhideif" "css_element" should not be visible
-
- Scenario: When 'notchecked' hideIf conditions are not met, the relevant elements are shown
- When I set the field "Checkbox example" to "1"
- Then I should see "Test not checked hideif"
And "#id_testnotcheckedhideif" "css_element" should be visible
-
- Scenario: When 'notchecked' hideIf conditions are met, the relevant elements are hidden
- When I set the field "Checkbox example" to "0"
- Then I should not see "Test not checked hideif"
- And "#id_testnotcheckedhideif" "css_element" should not be visible
+ And I press "Submit"
+ And I should see "Number of submitted form elements: 5"
+ And I should not see "[testcheckedhideif] =>"
+ And I should see "[testnotcheckedhideif] =>"
Scenario: When 'in' hideIf conditions are not met, the relevant elements are shown
When I set the field "Select example" to "3"
Then I should see "Test in hideif"
And "#id_testinhideif" "css_element" should be visible
+ And I press "Submit"
+ And I should see "Number of submitted form elements: 6"
+ And I should see "[testinhideif] =>"
Scenario: When 'in' hideIf conditions are met, the relevant elements are hidden
When I set the field "Select example" to "2"
Then I should not see "Test in hideif"
And "#id_testinhideif" "css_element" should not be visible
+ And I press "Submit"
+ And I should see "Number of submitted form elements: 5"
+ And I should not see "[testinhideif] =>"
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-require_once(dirname(__FILE__).'/../../../../config.php');
+require_once(__DIR__.'/../../../../config.php');
global $CFG, $PAGE, $OUTPUT;
require_once($CFG->libdir.'/formslib.php');
$mform->addElement('text', 'testinhideif', 'Test in hideif');
$mform->setType('testinhideif', PARAM_TEXT);
$mform->hideIf('testinhideif', 'selectexample', 'in', [1, 2, 5]);
+
+ $mform->addElement('submit', 'submitform', 'Submit');
}
}
-$PAGE->set_url('/lib/tests/fixtures/form_hideif.php');
+$PAGE->set_url('/lib/form/tests/fixtures/formhideiftestpage.php');
$PAGE->set_context(context_system::instance());
$form = new hideif_form();
echo $OUTPUT->header();
+if ($data = $form->get_data()) {
+ echo "<p>Number of submitted form elements: " . count((array)$data) . "</p>";
+ print_object($data);
+}
$form->display();
echo $OUTPUT->footer();