Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-39187 forms: fixed issue where calendar pop-up did not display wh…

…en a date selector form element was added to a group
  • Loading branch information...
commit 34f9862edf302f209b112808fffde0a89248f6b0 1 parent 95190fd
@markn86 markn86 authored
View
26 lib/form/dateselector.php
@@ -55,10 +55,19 @@ class MoodleQuickForm_date_selector extends MoodleQuickForm_group
protected $_options = array('startyear' => 1970, 'stopyear' => 2020,
'timezone' => 99, 'optional' => false);
- /** @var array These complement separators, they are appended to the resultant HTML */
+ /**
+ * @var array These complement separators, they are appended to the resultant HTML.
+ */
protected $_wrap = array('', '');
/**
+ * @var null|bool Keeps track of whether the date selector was initialised using createElement
+ * or addElement. If true, createElement was used signifying the element has been
+ * added to a group - see MDL-39187.
+ */
+ protected $_usedcreateelement = true;
+
+ /**
* constructor
*
* @param string $elementName Element's name
@@ -177,6 +186,10 @@ function onQuickFormEvent($event, $arg, &$caller)
}
return parent::onQuickFormEvent($event, $arg, $caller);
break;
+ case 'addElement':
+ $this->_usedcreateelement = false;
+ return parent::onQuickFormEvent($event, $arg, $caller);
+ break;
default:
return parent::onQuickFormEvent($event, $arg, $caller);
}
@@ -193,7 +206,16 @@ function toHtml()
$renderer = new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate('{element}');
parent::accept($renderer);
- return $this->_wrap[0] . $renderer->toHtml() . $this->_wrap[1];
+
+ $html = $this->_wrap[0];
+ if ($this->_usedcreateelement) {
+ $html .= html_writer::tag('span', $renderer->toHtml(), array('class' => 'fdate_selector'));
+ } else {
+ $html .= $renderer->toHtml();
+ }
+ $html .= $this->_wrap[1];
+
+ return $html;
}
/**
View
28 lib/form/datetimeselector.php
@@ -56,8 +56,17 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group{
var $_options = array('startyear' => 1970, 'stopyear' => 2020, 'defaulttime' => 0,
'timezone' => 99, 'step' => 5, 'optional' => false);
- /** @var array These complement separators, they are appended to the resultant HTML */
- var $_wrap = array('', '');
+ /**
+ * @var array These complement separators, they are appended to the resultant HTML.
+ */
+ protected $_wrap = array('', '');
+
+ /**
+ * @var null|bool Keeps track of whether the date selector was initialised using createElement
+ * or addElement. If true, createElement was used signifying the element has been
+ * added to a group - see MDL-39187.
+ */
+ protected $_usedcreateelement = true;
/**
* Class constructor
@@ -196,6 +205,10 @@ function onQuickFormEvent($event, $arg, &$caller)
}
return parent::onQuickFormEvent($event, $arg, $caller);
break;
+ case 'addElement':
+ $this->_usedcreateelement = false;
+ return parent::onQuickFormEvent($event, $arg, $caller);
+ break;
default:
return parent::onQuickFormEvent($event, $arg, $caller);
}
@@ -212,7 +225,16 @@ function toHtml()
$renderer = new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate('{element}');
parent::accept($renderer);
- return $this->_wrap[0] . $renderer->toHtml() . $this->_wrap[1];
+
+ $html = $this->_wrap[0];
+ if ($this->_usedcreateelement) {
+ $html .= html_writer::tag('span', $renderer->toHtml(), array('class' => 'fdate_time_selector'));
+ } else {
+ $html .= $renderer->toHtml();
+ }
+ $html .= $this->_wrap[1];
+
+ return $html;
}
/**
View
4 lib/form/yui/dateselector/dateselector.js
@@ -189,11 +189,11 @@ YUI.add('moodle-form-dateselector', function(Y) {
if (this.panel === null) {
this.initPanel(config);
}
- Y.all('fieldset.fdate_time_selector').each(function(){
+ Y.all('.fdate_time_selector').each(function() {
config.node = this;
new CALENDAR(config);
});
- Y.all('fieldset.fdate_selector').each(function(){
+ Y.all('.fdate_selector').each(function() {
config.node = this;
new CALENDAR(config);
});
Please sign in to comment.
Something went wrong with that request. Please try again.