]> git.mjollnir.org Git - moodle.git/commitdiff
fixed a couple of bugs in custom elements
authorjamiesensei <jamiesensei>
Tue, 21 Nov 2006 10:14:38 +0000 (10:14 +0000)
committerjamiesensei <jamiesensei>
Tue, 21 Nov 2006 10:14:38 +0000 (10:14 +0000)
lib/form/datetimeselector.php
lib/form/submit.php

index c5a885f342efa620a29ed2493d72ccd55f70b8a7..e405b744277bb44d13a88f7a9f858bceff79d916 100644 (file)
@@ -84,10 +84,10 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group{
             $minutes[$i] = sprintf("%02d",$i);
         }
         $this->_elements[] =& MoodleQuickForm::createElement('select', 'day', null, $days, $this->getAttributes(), true);
-        $this->_elements[] =& MoodleQuickForm::createElement('select','month', null, $months, $this->getAttributes(), true);
-        $this->_elements[] =& MoodleQuickForm::createElement('select','year', null, $years, $this->getAttributes(), true);
+        $this->_elements[] =& MoodleQuickForm::createElement('select', 'month', null, $months, $this->getAttributes(), true);
+        $this->_elements[] =& MoodleQuickForm::createElement('select', 'year', null, $years, $this->getAttributes(), true);
         $this->_elements[] =& MoodleQuickForm::createElement('select', 'hour', null, $hours, $this->getAttributes(), true);
-        $this->_elements[] =& MoodleQuickForm::createElement('select','minute', null, $minutes, $this->getAttributes(), true);
+        $this->_elements[] =& MoodleQuickForm::createElement('select', 'minute', null, $minutes, $this->getAttributes(), true);
 
         $this->setValue();
     }
@@ -154,20 +154,28 @@ class MoodleQuickForm_date_time_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);
-        $valuearray +=$this->_elements[3]->exportValue($submitValues[$this->getName()], true);
-        $valuearray +=$this->_elements[4]->exportValue($submitValues[$this->getName()], true);
-        $value[$this->getName()]=make_timestamp($valuearray['year'],
-                               $valuearray['month'],
-                               $valuearray['day'],
-                               $valuearray['hour'],
-                               $valuearray['minute'],
-                               0,
-                               $this->_options['timezone'],
-                               $this->_options['applydst']);
-        return $value;
+        print_object($submitValues);
+        $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'],
+                                   $valuearray['hour'],
+                                   $valuearray['minute'],
+                                   0,
+                                   $this->_options['timezone'],
+                                   $this->_options['applydst']);
+
+            return $value;
+        } else {
+            return null;
+        }
     }
 
     // }}}
index 6e1203cfc35bb398f8e2f9acfdadd4a2f66dfd0a..05669f262364c0ecbb2b2d29852a67fb85d8157c 100644 (file)
@@ -25,7 +25,7 @@ class MoodleQuickForm_submit extends HTML_QuickForm_submit
     function MoodleQuickForm_submit($elementName=null, $value=null, $attributes=null)
     {
         HTML_QuickForm_submit::HTML_QuickForm_submit($elementName, $value, $attributes);
-        if ($elementName='cancel'){
+        if ('cancel'==$elementName){
             //bypass form validation js :
             $this->updateAttributes(array('onclick'=>'this.form.submit();'));
         }