Multiple disableIf depending on the same element does not work well in Moodle 2.2 (it's fine in Moodle 2.1)
For example, assuming that I have a select box and a textbox
$mform->addElement('select', 'select1', get_string('...', '...'), array(1, 2, 3, 4));
$mform->addElement('text', 'text1', get_string('...', '...')_;
I'd like to disable the text when select = 1 or 2
$mform->disabledIf('text1', 'select1', 'eq', 1);
$mform->disabledIf('text1', 'select1', 'eq', 2);
In Moodle 2.2, just the first disabledIf command works. The second one is "hidden" by the first. Some debugging led me to the function convert_to_array in moodle_lib.php, the in_array condition eliminate the second rule so it doesn't appear in the json object passed to the javascript:
foreach ($var as $key => $value) {
// recursively convert objects
if (is_object($value) || is_array($value)) {
// but prevent cycles
if (!in_array($value, $references)) {
$result[$key] = convert_to_array($value);
$references[] = $value;
}
} else {
// simple values are untouched
$result[$key] = $value;
}
}
Did someone encounter it or fix it yet!