MDL-78484 formslib: Move enable checkbox display before the date picker

This commit is contained in:
hieuvu 2023-06-22 09:00:33 +07:00
parent 64b701190d
commit 14079fa738
2 changed files with 10 additions and 8 deletions

View File

@ -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);

View File

@ -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);