It doesn't look like you're using the FormHelper's methods properly.
Looking at the API, and just the minute's method, I see it's
incorrectly used.
function minute($fieldName, $selected = null, $attributes = array(),
$showEmpty = true){
//...
}
Check the book (book.cakephp.org) and Core Helpers to understand how
to use the Form methods with proper syntax and parameters. (I think
you already have an idea of how to use them, but if it asks for an
array, supply it with an array or you might get undesirable and
unexpected results.)
On May 26, 12:24 pm, Bs <[email protected]> wrote:
> Hi Stu,
>
> I tried it out with "datetime" column but that doesn't work, either.
> Result is "null" in the column.
> Here's part of my code:
>
> add.cpt:
> ...
> <tr>
> <td style="text-align:right;">Opening time</td>
> <td style="text-align:left;">from <?php echo $form->hour
> ('OpeningStartHours',1,6);?> : <?php echo $form->minute
> ('OpeningStartMinutes',0,null,"00");?>
> to <?php echo
> $form->hour('OpeningEndHours',
> 1,18);?> : <?php echo $form->minute('OpeningEndMinutes',0,null,"00");?>
> o'clock
>
> </td>
> </tr>
> ...
>
> mycontroller:
> ....
> function add() {
> ....
> $startMinutes = $data['myobject']['OpeningStartMinutes'];
> $startHours = $data['myobject']['OpeningStartHours'];
> $endMinutes = $data['myobject']['OpeningEndMinutes'];
> $endHours = $data['myobject']['OpeningEndHours'];
> $data['myobject']['OpeningStartMinutes'] = $startMinutes['min'];
> $data['myobject']['OpeningStartHours'] = $startHours['hour'];
> $data['myobject']['OpeningEndMinutes'] = $endMinutes['min'];
> $data['myobject']['OpeningEndHours'] = $endHours['hour'];
> ....
>
> That way it works, but of course it's quite complicated always
> converting those values and storing them in 4 different fields.
>
> After your hint I tried it with a datetime "OpeningStart" and
> "OpeningEnd" field like this
> ...
> <tr>
> <td style="text-align:right;">Opening time</td>
> <td style="text-align:left;">from <?php echo $form->hour
> ('OpeningStart',1,6);?> : <?php echo $form->minute('OpeningStart',
> 0,null,"00");?>
> to <?php echo
> $form->hour('OpeningEnd',1,18);?> :
> <?php echo $form->minute('OpeningEnd',0,null,"00");?> o'clock
> </td>
> </tr>
> ...
>
> and commented out the conversion code in my controller, but that
> resulted in "null" values for "OpeningStart" and "OpeningEnd" in the
> database.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---