#6488: time dropdowns generate a NULL on insert when midnight is selected
    Reporter:  calzone                                 |          Type:  Bug    
      Status:  new                                     |      Priority:  High   
   Milestone:  1.2.x.x                                 |     Component:  Helpers
     Version:  1.2 Final                               |      Severity:  Major  
    Keywords:  form helper time dropdowns null insert  |   Php_version:  PHP 5  
Cake_version:                              |  
 Using the form helper to generate fields for a MySQL column of type TIME
 (not datetime!) results in three dropdown menus as expected (hour - min -

 However, upon submitting this form, if the user selects a time of midnight
 (12:00am), Cake then attempts to insert a NULL value for the TIME field
 into the database.

 My specific ctp configuration for this field, in case it matters, included
 defining the interval:
 echo $form->input('starts',array('label'=>'starts','interval'=>30));
 Cake is translating the value of 12:00 am to NULL.  I assume this is
 because 12am is the same as 0, and 0 is being expressed as NULL but this
 is just a wild guess. I have no actual clue.

 On submit, my controller is not processing the data, and has nothing
 fancy, just:
 It works perfectly fine for all other time values.  It's just midnight
 that messes it up.

 I have set the priority and severity moderately high for this bug as
 midnight is a fairly common time selection and this effectively kills the
 ability to seamlessly save user inputted data under those conditions as
 the database either needs to be configured to accept null values for this
 field and the developer must later somehow account for null values as if
 they were midnight values, or the query must result in an error with no
 data saved to the database.

 The only workaround I can think of would be to completely rehash the
 $this->data array and manually create a single time field from the three
 individual dropdowns for every time these are used in a form and to then
 replace the $this->data array with the new custom rehashed array.  For
 many developers, this is probably not obvious, and the bug itself may not
 even come up in casual testing.

Ticket URL: <https://trac.cakephp.org/ticket/6488>
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 

  • [CakePHP : The Rapid Dev... CakePHP : The Rapid Development Framework for PHP

Reply via email to