mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-53848 formslib: make conditional hidden elements properly accessible
This commit is contained in:
parent
f3da329da4
commit
988879655b
@ -266,6 +266,7 @@ if (typeof M.form.dependencyManager === 'undefined') {
|
||||
els.each(function(node) {
|
||||
var e = node.ancestor('.fitem');
|
||||
if (e) {
|
||||
(hidden) ? e.setAttribute('hidden', 'hidden') : e.removeAttribute('hidden');
|
||||
e.setStyles({
|
||||
display: (hidden) ? 'none' : ''
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
@core @javascript
|
||||
@core @javascript @core_form
|
||||
Feature: hideIf functionality in forms
|
||||
For forms including hideIf functions
|
||||
As a user
|
||||
@ -8,7 +8,9 @@ Feature: hideIf functionality in forms
|
||||
Given the following "activities" exist:
|
||||
| activity | name | intro | course | section | idnumber |
|
||||
| label | L1 | <a href="lib/form/tests/fixtures/formhideiftestpage.php">HideIfLink</a> | Acceptance test site | 1 | L1 |
|
||||
And I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I wait "5" seconds
|
||||
And I follow "HideIfLink"
|
||||
|
||||
Scenario: When 'eq' hideIf conditions are not met, the relevant elements are shown
|
||||
@ -52,14 +54,18 @@ Feature: hideIf functionality in forms
|
||||
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 I should see "Date time example"
|
||||
And I should see "Files"
|
||||
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 "Number of submitted form elements: 8"
|
||||
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 I should not see "Date time example"
|
||||
And I should not see "Files"
|
||||
And "#id_testinhideif" "css_element" should not be visible
|
||||
And I press "Submit"
|
||||
And I should see "Number of submitted form elements: 5"
|
||||
|
@ -71,6 +71,10 @@ class hideif_form extends moodleform {
|
||||
$mform->addElement('text', 'testinhideif', 'Test in hideif');
|
||||
$mform->setType('testinhideif', PARAM_TEXT);
|
||||
$mform->hideIf('testinhideif', 'selectexample', 'in', [1, 2, 5]);
|
||||
$mform->addElement('date_time_selector', 'testdatetime', 'Date time example', array('optional' => true));
|
||||
$mform->hideIf('testdatetime', 'selectexample', 'in', [1, 2, 5]);
|
||||
$mform->addElement('filemanager', 'files_filemanager', 'Files', null, array());
|
||||
$mform->hideIf('files_filemanager', 'selectexample', 'in', [1, 2, 5]);
|
||||
|
||||
$mform->addElement('submit', 'submitform', 'Submit');
|
||||
}
|
||||
|
@ -1466,9 +1466,13 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
|
||||
protected $clientvalidation = false;
|
||||
|
||||
/**
|
||||
* Is this a 'disableIf' dependency of a 'hideIf' dependency?
|
||||
* Is this a 'disableIf' dependency ?
|
||||
*/
|
||||
const DEP_DISABLE = 0;
|
||||
|
||||
/**
|
||||
* Is this a 'hideIf' dependency?
|
||||
*/
|
||||
const DEP_HIDE = 1;
|
||||
|
||||
/**
|
||||
@ -2454,7 +2458,7 @@ require(["core/event", "jquery"], function(Event, $) {
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($this->_hideifs as $dependenton => $conditions){
|
||||
foreach ($this->_hideifs as $dependenton => $conditions) {
|
||||
$result[$dependenton] = array();
|
||||
foreach ($conditions as $condition => $values) {
|
||||
$result[$dependenton][$condition] = array();
|
||||
|
Loading…
x
Reference in New Issue
Block a user