Browse Source

Fix DateTime and Date pickers when they belongs to group - refs BT#10175

Angel Fernando Quiroz Campos 9 years ago
parent
commit
5857591725

+ 22 - 2
main/inc/lib/formvalidator/Element/DatePicker.php

@@ -32,9 +32,29 @@ class DatePicker extends HTML_QuickForm_text
     */
     public function toHtml()
     {
-        $js = $this->getElementJS();
+        if ($this->_flagFrozen) {
+            return $this->getFrozenHtml();
+        }
+
+        $id = $this->getAttribute('id');
+        $value = $this->getValue();
+
+        if (!empty($value)) {
+            $value = api_format_date($value, DATE_TIME_FORMAT_LONG_24H);
+        }
+
+        if (empty($this->getLabel())) {
+            return $this->getElementJS() . '
+                <div class="input-group">
+                    <span class="input-group-addon">
+                        <input ' . $this->_getAttrString($this->_attributes) . '>
+                    </span>
+                    <input class="form-control" type="text" readonly id="' . $id . '_alt" value="' . $value . '">
+                </div>
+            ';
+        }
 
-        return $js.parent::toHtml();
+        return $this->getElementJS() . parent::toHtml();
     }
 
     /**

+ 22 - 2
main/inc/lib/formvalidator/Element/DateTimePicker.php

@@ -26,9 +26,29 @@ class DateTimePicker extends HTML_QuickForm_text
      */
     public function toHtml()
     {
-        $js = $this->getElementJS();
+        if ($this->_flagFrozen) {
+            return $this->getFrozenHtml();
+        }
+
+        $id = $this->getAttribute('id');
+        $value = $this->getValue();
+
+        if (!empty($value)) {
+            $value = api_format_date($value, DATE_TIME_FORMAT_LONG_24H);
+        }
+
+        if (empty($this->getLabel())) {
+            return $this->getElementJS() . '
+                <div class="input-group">
+                    <span class="input-group-addon">
+                        <input ' . $this->_getAttrString($this->_attributes) . '>
+                    </span>
+                    <input class="form-control" type="text" readonly id="' . $id . '_alt" value="' . $value . '">
+                </div>
+            ';
+        }
 
-        return $js.parent::toHtml();
+        return $this->getElementJS() . parent::toHtml();
     }
 
     /**