In one of the latest SVN versions of CakePHP this seems to have been redone.
It now returns:
['to']['year']
['to']['month']
['to']['day']

cleanUpFields is gone. It should be done automatically through the model,
BUT I can't get it to save to the database. Out well.

On Dec 5, 2007 9:51 PM, Baz <[EMAIL PROTECTED]> wrote:

> Hey, thanX for all the help people.
>
> I took the lazy way out though. I copied a huge chunk outta cleanUpFields.
> Actually, it's more like I removed the loops.
>
> So now I got this:
> function cleanUpField($field, $type, $modelClass = null)
>
> And I call it like:
> $this->cleanUpFiend('to', 'date');
> $this->cleanUpFiend('from', 'date');
> $this->cleanUpFiend('time', 'time');
>
> Works like a charm.
>
> Let me know if there's somewhere I can paste this just in case someone
> else wants it.
> --
> Baz L
> Web Development 2.0: Web Design, CakePHP, Javascript
> http://www.WebDevelopment2.com/
>
> On Dec 5, 2007 8:48 AM, Baz <[EMAIL PROTECTED]> wrote:
>
> > Ouch, ok.
> >
> > My *actual* problem is specific to time however: [1]:[02] [AM] becomings
> > - [1]:[2] in $this->data. Therefore, becoming "1:2am" in my string and
> > causing me strtotime to fail.
> >
> > OK, I'll just use my own fields. I just thought there was a simpler
> > method. Just figured if it's there, I should be using it.
> >
> > ThanX all.
> > --
> > Baz L
> > Web Development 2.0
> > http://WebDevelopment2.com/
> >
> >
> > On Dec 5, 2007 8:41 AM, Adam Royle < [EMAIL PROTECTED]> wrote:
> >
> > >
> > > With AD's technique (which looks kinda cool), you would still need to
> > > write a custom method to handle the data conversion from your date
> > > input to an sql datetime.
> > >
> > > All depends on your form I guess. Since I'm in Australia, I want to
> > > convert my form fields from
> > >
> > > dd/mm/yyyy (aus format) to yyyy-mm-dd (sql format)
> > >
> > > and my time from "4:15pm" to 16:15:00
> > >
> > > So I have a function to convert the date format - a simple regex:
> > >
> > > function convertToSQLDate($date){
> > >        $date =
> > > preg_replace('/^(\d{1,2})\/(\d{1,2})\/(\d{2,4})$/','$3-$2-
> > > $1', $date);
> > >        $date = date('Y-m-d',strtotime($date));
> > >        return $date;
> > > }
> > >
> > >
> > > And then I create a new string with the sql date I converted above,
> > > append the time string and send to strtotime...
> > >
> > > // so equivalent to doing something like this
> > > echo date('Y-m-d H:i:s',strtotime('2007-12-05 4pm'));
> > >
> > > And voila... your new sql date string is ready :)
> > >
> > > Sorry if that's a bit confusing, it's almost 1am here.
> > >
> > > Cheers,
> > > Adam
> > >
> > > On Dec 5, 11:48 pm, Baz <[EMAIL PROTECTED]> wrote:
> > > > Sorry AD, you've totally lost me.
> > > > --
> > > > Baz L
> > > > Web Development 2.0: Web Design, CakePHP,
> > > Javascripthttp://www.WebDevelopment2.com/
> > > >
> > > > On Dec 5, 2007 5:09 AM, AD7six < [EMAIL PROTECTED]> wrote:
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > > On Dec 5, 8:57 am, Baz <[EMAIL PROTECTED]> wrote:
> > > > > > OK,
> > > >
> > > > > > I've banged my head against the wall a million times. This is my
> > > > > problem:
> > > >
> > > > > > I got date and time fields which I need. They are not associated
> > > with
> > > > > the
> > > > > > model or database.
> > > >
> > > > > > I call them like so:
> > > >
> > > > > >         echo $form->input('from', array('label' => 'From',
> > > 'type' =>
> > > > > 'date',
> > > > > > 'div' => 'date'));
> > > > > >         echo $form->input('to', array('label' => 'To', 'type' =>
> > > 'date',
> > > > > > 'div' => 'date'));
> > > > > >         echo $form->input('time', array('label' => 'Time',
> > > 'type' =>
> > > > > 'time',
> > > > > > 'div' => 'date'));
> > > >
> > > > > > However, cleanUpFields doesn't work it's magic like if those
> > > fields were
> > > > > in
> > > > > > the database.
> > > >
> > > > > > Any ideas?
> > > > > > Is there a way to force the model to consider those fields as
> > > its own?
> > > >
> > > > > As things move quite fast, it depends on your cake revision. As of
> > > > > right now override the schema method, call the parent and then add
> > > an
> > > > > entry for your virtual field.
> > > >
> > > > >
> > > https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/model/mod.
> > > ..
> > > >
> > > > > Although it doesn't make a lot of sense to override schema for a
> > > model
> > > > > that /does/ have a table. you'd normally do so only for a model
> > > with
> > > > > no table, such as the model for validation a contact message, so
> > > that
> > > > > forms work etc.
> > > >
> > > > > hth,
> > > >
> > > > > AD
> > > > > >
> > >
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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