Changeset 1364

Show
Ignore:
Timestamp:
12/29/11 14:43:18 (18 months ago)
Author:
alex94040
Message:

Fixes #734 (QDatepickerBox: default to NULL date). Code by vakopian, review by alex94040.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • framework/branches/2.0/includes/qcubed/_core/base_controls/QDatepickerBoxBase.class.php

    r1295 r1364  
    11<?php 
    2     /** 
     2 
     3        /** 
    34         * @property string $DateFormat 
    45         * @property string $DateTimeFormat 
     
    89         * 
    910         */ 
    10         class QDatepickerBoxBase extends QDatepickerBoxGen 
    11         { 
    12                 protected $strDateTimeFormat = "MM/DD/YY";      // matches default of JQuery UI control 
     11        class QDatepickerBoxBase extends QDatepickerBoxGen { 
     12                protected $strDateTimeFormat = "MM/DD/YY"; // matches default of JQuery UI control 
     13                /** @var QDateTime */ 
    1314                protected $dttDateTime; 
    1415 
    15         public function ParsePostData() { 
    16             // Check to see if this Control's Value was passed in via the POST data 
    17             if (array_key_exists($this->strControlId, $_POST)) { 
    18                 parent::ParsePostData(); 
    19                 $this->dttDateTime = new QDateTime($this->strText); 
    20             } 
    21         } 
     16                public function ParsePostData() { 
     17                        // Check to see if this Control's Value was passed in via the POST data 
     18                        if (array_key_exists($this->strControlId, $_POST)) { 
     19                                parent::ParsePostData(); 
     20                                $this->dttDateTime = new QDateTime($this->strText); 
     21                                if ($this->dttDateTime->IsNull()) { 
     22                                        $this->dttDateTime = null; 
     23                                } 
     24                        } 
     25                } 
    2226 
    2327                public function Validate() { 
     
    5761                        switch ($strName) { 
    5862                                // MISC 
    59                                 case "Maximum": return $this->MaxDate; 
    60                                 case "Minimum": return $this->MinDate; 
     63                                case "Maximum": 
     64                                        return $this->MaxDate; 
     65                                case "Minimum": 
     66                                        return $this->MinDate; 
    6167                                case 'DateTimeFormat': 
    62                                 case 'DateFormat': return $this->strDateTimeFormat; 
    63                                 case 'DateTime': return $this->dttDateTime; 
     68                                case 'DateFormat': 
     69                                        return $this->strDateTimeFormat; 
     70                                case 'DateTime': 
     71                                        return $this->dttDateTime; 
    6472 
    6573                                default: 
     
    7280                        } 
    7381                } 
     82 
    7483                ///////////////////////// 
    7584                // Public Properties: SET 
     
    98107                                        try { 
    99108                                                $this->dttDateTime = QType::Cast($mixValue, QType::DateTime); 
     109                                                if ($this->dttDateTime->IsNull()) { 
     110                                                        $this->dttDateTime = null; 
     111                                                } 
    100112                                                if (!$this->dttDateTime || !$this->strDateTimeFormat) { 
    101113                                                        parent::__set('Text', ''); 
     
    150162                } 
    151163        } 
     164 
    152165?>