In the RC3 Stable version, I found where the issue lies.
Unfortunately, I'm not sure why the code is set the way it's set.  It
doesn't look like the 'time' datatype was missed "accidentally", but
purposefully left out.  Perhaps a database specific issue?

Line 805 of model.php in cake/libs/model in the Model::deconstruct()
method - if values are empty, and the field is of type DATETIME,
TIMESTAMP, or DATE, then null is returned.  The type TIME is not
included in this list, but it is at line 784 in a different IF block.
Would any one working on the core be able to clarify this?  For my own
purposes, it looks like I need to add 'time' to the IF block's array
at line 805, but I don't like modifying the core, and unfortunately
have never before written any unit tests.


On Oct 20, 5:29 pm, BrendonKoz <[EMAIL PROTECTED]> wrote:
> (Using Cake 1.2 RC3, and tried latest nightly,
> 1.2.x.x_20.10.2008.tar.gz)
>
> When using theFormHelperon fields that generate a select list, there
> is an option to use " 'empty'=>true" (or to swap out "true" for a
> string literal that is used as the textual label in the select box).
> Date, datetime, and time fields (I'm using MySQL) all are rendered as
> select boxes, for this example, ALL fields were set to ALLOW null
> values.
>
> When applying the 'empty' option to all three of these data types in
> both the add and edit views, my results are as follows:
> 1. Add form
>     - everything works as expected
>
> 2. Upon saving
>     - The database stores null value for date, and datetime types.
> `time` is stored as '00:00:00'.
>
> 3. Viewing the edit form
>     - `date`, and `datetime` fields are still shown (and selected by
> default) as the empty value(s)
>     - `time` is set to 12:00am, but theFormHelperstill shows an
> option for an empty selection, so at least it's rendering the select
> box properly.
>
> I've not yet tracked back where the transform happens (from an empty
> value to what I think is an invalid SQL value for a time field), but I
> don't know if this is intended behavior or not.  I do require the
> ability to save an empty value, or at the very least show an empty
> value on the edit form, but I can't seem to find a workaround.
>
> Does anyone have any advice or comments?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to