MDL-55804 forms: Return exported data through _prepareValue

This commit is contained in:
David Monllao
2016-09-27 08:12:08 +08:00
parent 6aec209125
commit 8b27687b5f
5 changed files with 9 additions and 13 deletions
+3 -5
View File
@@ -262,7 +262,6 @@ class MoodleQuickForm_date_selector extends MoodleQuickForm_group {
* @return array
*/
function exportValue(&$submitValues, $assoc = false) {
$value = null;
$valuearray = array();
foreach ($this->_elements as $element){
$thisexport = $element->exportValue($submitValues[$this->getName()], true);
@@ -274,21 +273,20 @@ class MoodleQuickForm_date_selector extends MoodleQuickForm_group {
if($this->_options['optional']) {
// If checkbox is on, the value is zero, so go no further
if(empty($valuearray['enabled'])) {
$value[$this->getName()] = 0;
return $value;
return $this->_prepareValue(0, $assoc);
}
}
// Get the calendar type used - see MDL-18375.
$calendartype = \core_calendar\type_factory::get_calendar_instance();
$gregoriandate = $calendartype->convert_to_gregorian($valuearray['year'], $valuearray['month'], $valuearray['day']);
$value[$this->getName()] = make_timestamp($gregoriandate['year'],
$value = make_timestamp($gregoriandate['year'],
$gregoriandate['month'],
$gregoriandate['day'],
0, 0, 0,
$this->_options['timezone'],
true);
return $value;
return $this->_prepareValue($value, $assoc);
} else {
return null;
}