MDL-39463 forms: use the date selectors 'optional' parameter rather than creating additional logic

This commit is contained in:
Mark Nelson
2013-05-08 16:36:54 +08:00
parent 2fd46e12b8
commit e019dcccdf
6 changed files with 29 additions and 96 deletions
+11 -1
View File
@@ -201,7 +201,17 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group{
break;
case 'createElement':
if($arg[2]['optional']) {
$caller->disabledIf($arg[0], $arg[0].'[enabled]');
// When using the function addElement, rather than createElement, we still
// enter this case, making this check necessary.
if ($this->_usedcreateelement) {
$caller->disabledIf($arg[0] . '[day]', $arg[0] . '[enabled]');
$caller->disabledIf($arg[0] . '[month]', $arg[0] . '[enabled]');
$caller->disabledIf($arg[0] . '[year]', $arg[0] . '[enabled]');
$caller->disabledIf($arg[0] . '[hour]', $arg[0] . '[enabled]');
$caller->disabledIf($arg[0] . '[minute]', $arg[0] . '[enabled]');
} else {
$caller->disabledIf($arg[0], $arg[0] . '[enabled]');
}
}
return parent::onQuickFormEvent($event, $arg, $caller);
break;