#6488: time dropdowns generate a NULL on insert when midnight is selected
    Reporter:  calzone                                 |         Owner:  
        Type:  Bug                                     |        Status:  
    Priority:  High                                    |     Milestone:  
   Component:  Helpers                                 |       Version:  1.2 
    Severity:  Major                                   |    Resolution:         
    Keywords:  form helper time dropdowns null insert  |   Php_version:  PHP 5  
Cake_version:                              |  
Comment (by youheiogino):

 I met this bug a few months ago, and found similar trouble in the
 following article in "google gruop archives".[[BR]]
 In this article, Brendon Kozlowski (aka BrendonCoz) said that a bug seems
 to be introduced from his patch.
 His patch can be found here.[[BR]]
 I tried to comment out his 3 lines patch code at "model.php".[[BR]]
 But all TIME value of unselected dropdown menu became "00:00:00".
 So I changed other part at same file.[[BR]]
       foreach ($dateFields as $key => $val) {
         if (in_array($val, array('hour', 'min', 'sec'))) {
           if (!isset($data[$val]) || ($data[$val] == null)) {
 //          if (!isset($data[$val]) || $data[$val] === '0' ||
 empty($data[$val])) {
 //            $data[$val] = '00';
           } else {
             $data[$val] = sprintf('%02d', $data[$val]);
         if (in_array($type, array('datetime', 'timestamp', 'date')) &&
 !isset($data[$val]) || isset($data[$val]) && (empty($data[$val]) ||
 $data[$val][0] === '-')) {
           return null;
         } elseif (isset($data[$val]) && !empty($data[$val])) {
           $date[$key] = $data[$val];
       $date = str_replace(array_keys($date), array_values($date),
 //      if ($type == 'time' && $date == '00:00:00') {
 //        return null;
 //      }


Ticket URL: <https://trac.cakephp.org/ticket/6488#comment:2>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" group.
To post to this group, send email to tickets-cakephp@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to