Model::deconstruct() may be what you are looking for. I had some
trouble with a save() call that wouldn't work with the date array from
formhelper. I think save() is supposed to call deconstruct, which
turns arrays from the form into the right format for the insert. My
save() was choking on the date array for me - not sure why. calling
deconstruct on the date put it into a format I could use:
Model::deconstruct($data['Post']['date']);
where $data['Post']['date'] = array('year'=>(year),'month'=>
(month),'day'=>(day),.. etc]
or
Model::deconstruct($params['form']['date']);
or maybe it was: $this->Post->deconstruct($params['form']['date']) - i
don't remember exactly.
Course your form is not returning your times in the right format for
deconstruct to work.
If OpeningStartMinutes is your field name, I believe you want:
<?php echo $form->hour
('OpeningStart.Hours',1,6);?> : <?php echo $form->minute
('OpeningStart.Minutes',0,null,"00");?>
to <?php echo $form-
>hour('OpeningEnd.Hours',
1,18);?> : <?php echo $form->minute('OpeningEnd.Minutes',0,null,"00");?
>
Or something like that, which will return your data object like:
$data['myobject']['OpeningStart']['Minutes'];
$data['myobject']['OpeningStart']['Hours'];
$data['myobject']['OpeningEnd']['Minutes'];
$data['myobject']['OpeningEnd']['Hours'];
Which ought to deconstruct() into two fields that are properly
formatted for the two corresponding table names, provided your tables
are named: OpeningStart and OpeningEnd (according to convention).
If it's not happening automatically you can call deconstruct() like:
$data['myobject']['OpeningStart'] = Model::deconstruct($data
['myobject']['OpeningStart'])
as a quicky - at least that's what I did. It ought to happen
automatically though.
By the way if you are using versions before 1.2 the method in the
controller is: $this->cleanUpFields()
cheers
On May 26, 8:14 am, Bs <[email protected]> wrote:
> Hi,
>
> I'm new here and just wanna say first that I'm absolutely in love with
> CakePHP and will definitely donate for this project. This framework
> saves me work each day.
>
> I have a question about handling "minute" and "hour" elements in
> forms. I'm using those for setting a start and end time in my model.
> What irritates me is the way those values are handled by Cake, cause
> Cake puts the values of those fields in arrays with the keys "min" and
> "hour".
> Right now I'm drawing those values out of the array in my controller,
> cause MySQL can't handle those values inside of arrays by itself, of
> course.
> But is there any standard-method how to cope with those minute and
> time fields to automatically save them in my mysql table? Or is it
> always necessary to convert those arrays to your own data fields in
> your tables?
>
> Thanks in advance, B.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---