mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 12:45:04 +01:00
MDL-39187 forms: fixed issue where calendar pop-up did not display when a date selector form element was added to a group
This commit is contained in:
parent
95190fda69
commit
34f9862edf
@ -55,9 +55,18 @@ 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
|
||||
*
|
||||
@ -177,6 +186,10 @@ class MoodleQuickForm_date_selector extends MoodleQuickForm_group
|
||||
}
|
||||
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 @@ class MoodleQuickForm_date_selector extends MoodleQuickForm_group
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group{
|
||||
}
|
||||
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 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group{
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
4
lib/form/yui/dateselector/dateselector.js
vendored
4
lib/form/yui/dateselector/dateselector.js
vendored
@ -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);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user