]> git.mjollnir.org Git - moodle.git/commitdiff
a bug fix for custom element dateselector
authorjamiesensei <jamiesensei>
Tue, 21 Nov 2006 10:18:39 +0000 (10:18 +0000)
committerjamiesensei <jamiesensei>
Tue, 21 Nov 2006 10:18:39 +0000 (10:18 +0000)
lib/form/dateselector.php

index f9746ab0d1da248ea0451b2988b8d06597b2331c..7a3fab11fe7d20f064975040f2ef098d0db2d2ba 100644 (file)
@@ -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;
     }