Skip to content

Commit

Permalink
MDL-34859 forms: fix the checkbox in defaultcustom element
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Mar 22, 2017
1 parent 7f0ddd4 commit cc401e6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/form/defaultcustom.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function _createElements() {
if (!$this->has_customize_switch()) {
$element = $this->createFormElement('hidden', 'customize', 1);
} else {
$element = $this->createFormElement('checkbox', 'customize', '', $this->_options['customlabel']);
$element = $this->createFormElement('advcheckbox', 'customize', '', $this->_options['customlabel']);
}
$this->_elements[] = $element;

Expand Down Expand Up @@ -181,12 +181,14 @@ public function onQuickFormEvent($event, $arg, &$caller) {
break;
case 'createElement':
$rv = parent::onQuickFormEvent($event, $arg, $caller);
if ($this->_options['type'] === 'text') {
$caller->disabledIf($arg[0] . '[value]', $arg[0] . '[customize]', 'notchecked');
} else {
$caller->disabledIf($arg[0] . '[value][day]', $arg[0] . '[customize]', 'notchecked');
$caller->disabledIf($arg[0] . '[value][month]', $arg[0] . '[customize]', 'notchecked');
$caller->disabledIf($arg[0] . '[value][year]', $arg[0] . '[customize]', 'notchecked');
if ($this->has_customize_switch()) {
if ($this->_options['type'] === 'text') {
$caller->disabledIf($arg[0] . '[value]', $arg[0] . '[customize]', 'notchecked');
} else {
$caller->disabledIf($arg[0] . '[value][day]', $arg[0] . '[customize]', 'notchecked');
$caller->disabledIf($arg[0] . '[value][month]', $arg[0] . '[customize]', 'notchecked');
$caller->disabledIf($arg[0] . '[value][year]', $arg[0] . '[customize]', 'notchecked');
}
}
return $rv;
case 'addElement':
Expand Down

0 comments on commit cc401e6

Please sign in to comment.