From cc401e6f309abc1852b2b9d58995b71ac6fac3f5 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Wed, 22 Mar 2017 10:52:29 +0800 Subject: [PATCH] MDL-34859 forms: fix the checkbox in defaultcustom element --- lib/form/defaultcustom.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/form/defaultcustom.php b/lib/form/defaultcustom.php index a09d5660ecf..b8512aa091f 100644 --- a/lib/form/defaultcustom.php +++ b/lib/form/defaultcustom.php @@ -126,7 +126,7 @@ class MoodleQuickForm_defaultcustom extends MoodleQuickForm_group { 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; @@ -181,12 +181,14 @@ class MoodleQuickForm_defaultcustom extends MoodleQuickForm_group { 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':