Skip to content

Commit

Permalink
issue #5: match fields order to core date
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriim committed Nov 22, 2024
1 parent 22462e5 commit 13a25d6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions classes/datetime_limited.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,23 @@ public function _createElements() {

$this->_elements = [];

// 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->getAttributesForFormElement(), 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.
// Reverse date element (Should be: Day, Month, Year), in RTL mode.
$dateformat = array_reverse($dateformat);
}
foreach ($dateformat as $key => $date) {
// E_STRICT creating elements without forms is nasty because it internally uses $this.
$this->_elements[] = $this->createFormElement('select', $key, get_string($key, 'form'), $date, $this->getAttributes(), true);
$this->_elements[] = $this->createFormElement('select', $key, get_string($key, 'form'), $date, $this->getAttributesForFormElement(), true);
}

$this->_elements[] = $this->createFormElement('select', 'time', get_string('minute', 'form'),
$this->_options['timeslots'], $this->getAttributes(), true);
$this->_options['timeslots'], $this->getAttributesForFormElement(), true);


// The YUI2 calendar only supports the gregorian calendar type so only display the calendar image if this is being used.
Expand All @@ -139,10 +144,6 @@ public function _createElements() {
$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')){
Expand Down

0 comments on commit 13a25d6

Please sign in to comment.