Re: [CakePHP : The Rapid Development Framework for PHP] #6488: time dropdowns generate a NULL on insert when midnight is selected

2009-07-06 Thread CakePHP : The Rapid Development Framework for PHP
#6488: time dropdowns generate a NULL on insert when midnight is selected
---+
Reporter:  calzone | Owner:  
mark_story
Type:  Bug |Status:  
assigned  
Priority:  High| Milestone:  
1.2.x.x   
   Component:  Helpers |   Version:  1.2 
Final 
Severity:  Major   |Resolution: 
   
Keywords:  form helper time dropdowns null insert  |   Php_version:  PHP 5  
   
Cake_version:  1.2.3.8166  |  
---+
Comment (by youheiogino):

 Hello.[[BR]]
 [[BR]]
 I met this bug a few months ago, and found similar trouble in the
 following article in google gruop archives.[[BR]]
 [[BR]]
 http://groups.google.com/group/cake-
 php/browse_thread/thread/749bf75af77f295a
 [[BR]]
 [[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]]
 [[BR]]
 https://trac.cakephp.org/changeset/7782
 [[BR]]
 [[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]]
 [[BR]]
 Model.php[[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),
 $format);
 //  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 
flexibility.
--~--~-~--~~~---~--~~
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 
tickets-cakephp+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~--~~~~--~~--~--~---



[CakePHP : The Rapid Development Framework for PHP] #6488: time dropdowns generate a NULL on insert when midnight is selected

2009-07-02 Thread CakePHP : The Rapid Development Framework for PHP
#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:  1.2.3.8166  |  
---+
 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 -
 meridian).
 [[BR]][[BR]]

 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.
 [[BR]][[BR]]

 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.
 [[BR]][[BR]]

 On submit, my controller is not processing the data, and has nothing
 fancy, just:
 {{{
  $this-Inquiry-create();
  if($this-Inquiry-save($this-data))
 }}}
 It works perfectly fine for all other time values.  It's just midnight
 that messes it up.
 [[BR]][[BR]]

 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.
 [[BR]][[BR]]

 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 
flexibility.
--~--~-~--~~~---~--~~
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 
tickets-cakephp+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~--~~~~--~~--~--~---



Re: [CakePHP : The Rapid Development Framework for PHP] #6488: time dropdowns generate a NULL on insert when midnight is selected

2009-07-02 Thread CakePHP : The Rapid Development Framework for PHP
#6488: time dropdowns generate a NULL on insert when midnight is selected
---+
Reporter:  calzone | Owner:  
mark_story
Type:  Bug |Status:  
assigned  
Priority:  High| Milestone:  
1.2.x.x   
   Component:  Helpers |   Version:  1.2 
Final 
Severity:  Major   |Resolution: 
   
Keywords:  form helper time dropdowns null insert  |   Php_version:  PHP 5  
   
Cake_version:  1.2.3.8166  |  
---+
Changes (by mark_story):

  * owner:  = mark_story
  * status:  new = assigned

-- 
Ticket URL: https://trac.cakephp.org/ticket/6488#comment:1
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 
flexibility.
--~--~-~--~~~---~--~~
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 
tickets-cakephp+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~--~~~~--~~--~--~---