From 57cf1be250a8cf25410dd4fd3dafeba6226124d4 Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Tue, 21 Nov 2006 10:18:39 +0000 Subject: [PATCH] a bug fix for custom element dateselector --- lib/form/dateselector.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/form/dateselector.php b/lib/form/dateselector.php index f9746ab0d1..7a3fab11fe 100644 --- a/lib/form/dateselector.php +++ b/lib/form/dateselector.php @@ -142,15 +142,25 @@ class MoodleQuickForm_date_selector extends MoodleQuickForm_group function exportValue(&$submitValues, $assoc = false) { $value = null; - $valuearray = $this->_elements[0]->exportValue($submitValues[$this->getName()], true); - $valuearray +=$this->_elements[1]->exportValue($submitValues[$this->getName()], true); - $valuearray +=$this->_elements[2]->exportValue($submitValues[$this->getName()], true); - $value[$this->getName()]=make_timestamp($valuearray['year'], - $valuearray['month'], - $valuearray['day'], - 0,0,0, - $this->_options['timezone'], - $this->_options['applydst']); + $valuearray = array(); + foreach ($this->_elements as $element){ + $thisexport = $element->exportValue($submitValues[$this->getName()], true); + if ($thisexport!=null){ + $valuearray += $thisexport; + } + } + if (count($valuearray)){ + $value[$this->getName()]=make_timestamp($valuearray['year'], + $valuearray['month'], + $valuearray['day'], + 0,0,0, + $this->_options['timezone'], + $this->_options['applydst']); + + return $value; + } else { + return null; + } return $value; } -- 2.39.5