diff --git a/lib/form/dateselector.php b/lib/form/dateselector.php index 4ae8400ad72..467f09356e9 100644 --- a/lib/form/dateselector.php +++ b/lib/form/dateselector.php @@ -127,6 +127,11 @@ class MoodleQuickForm_date_selector extends MoodleQuickForm_group { if (right_to_left()) { $dateformat = array_reverse($dateformat); } + // If optional we add a checkbox which the user can use to turn if on. + if ($this->_options['optional']) { + $this->_elements[] = $this->createFormElement('checkbox', 'enabled', null, + get_string('enable'), $this->getAttributes(), true); + } foreach ($dateformat as $key => $value) { // E_STRICT creating elements without forms is nasty because it internally uses $this $this->_elements[] = $this->createFormElement('select', $key, get_string($key, 'form'), $value, $this->getAttributes(), true); @@ -137,10 +142,6 @@ class MoodleQuickForm_date_selector extends MoodleQuickForm_group { $this->_elements[] = $this->createFormElement('link', 'calendar', null, '#', $image); } - // If optional we add a checkbox which the user can use to turn if on - if ($this->_options['optional']) { - $this->_elements[] = $this->createFormElement('checkbox', 'enabled', null, get_string('enable'), $this->getAttributes(), true); - } foreach ($this->_elements as $element){ if (method_exists($element, 'setHiddenLabel')){ $element->setHiddenLabel(true); diff --git a/lib/form/datetimeselector.php b/lib/form/datetimeselector.php index a39b0814dad..4c15c26bee3 100644 --- a/lib/form/datetimeselector.php +++ b/lib/form/datetimeselector.php @@ -131,6 +131,11 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group { } $this->_elements = array(); + // If optional we add a checkbox which the user can use to turn if on. + if ($this->_options['optional']) { + $this->_elements[] = $this->createFormElement('checkbox', 'enabled', null, + get_string('enable'), $this->getAttributes(), true); + } $dateformat = $calendartype->get_date_order($this->_options['startyear'], $this->_options['stopyear']); if (right_to_left()) { // Display time to the right of date, in RTL mode. $this->_elements[] = $this->createFormElement('select', 'minute', get_string('minute', 'form'), @@ -156,10 +161,6 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group { $this->_elements[] = $this->createFormElement('link', 'calendar', null, '#', $image); } - // If optional we add a checkbox which the user can use to turn if on - if ($this->_options['optional']) { - $this->_elements[] = $this->createFormElement('checkbox', 'enabled', null, get_string('enable'), $this->getAttributes(), true); - } foreach ($this->_elements as $element){ if (method_exists($element, 'setHiddenLabel')){ $element->setHiddenLabel(true);