Re: Saving Date and Time NOT in the Model/Database (cleanUpFields not working)
There 'work around' doesn't exactly work: I'd have to override schema() in my model to add the fields. Then I could manually call deconstruct(). However, overriding schema will be done for ALL of the model's functions. I would then get problems when performing find('all'), etc. On Jan 13, 2:00 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Try: > > $property_formatted_date_string = $this->Model->deconstruct($this- > > >data['Model']['datefield']); > > When you're saving data, it seems to work fine without calling > Model::deconstruct, but if you're doing 'custom' date fields (e.g., > searching records in a database) it appears that you need to > deconstruct it yourself. When I updated from pre-beta to beta I ran > into this problem. > > - B. D. > > On Dec 11 2007, 2:04 pm, Baz <[EMAIL PROTECTED]> wrote: > > > It says it was replaced by: Model::deconstruct() > > > But the functionality is different. Doing a direct call didn't work for me. > > > Even if it did, there's another issue with the latest version not saving > > dates and times to the database. I think I'll just hold up on the SVN for > > now. At least until they update the API. > > > On Dec 11, 2007 9:33 AM, Gwoo <[EMAIL PROTECTED]> wrote: > > > > What does it saycleanUpFields() was replaced by? Maybe you could use > > > that --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Saving Date and Time NOT in the Model/Database (cleanUpFields not working)
Try: $property_formatted_date_string = $this->Model->deconstruct($this- >data['Model']['datefield']); When you're saving data, it seems to work fine without calling Model::deconstruct, but if you're doing 'custom' date fields (e.g., searching records in a database) it appears that you need to deconstruct it yourself. When I updated from pre-beta to beta I ran into this problem. - B. D. On Dec 11 2007, 2:04 pm, Baz <[EMAIL PROTECTED]> wrote: > It says it was replaced by: Model::deconstruct() > > But the functionality is different. Doing a direct call didn't work for me. > > Even if it did, there's another issue with the latest version not saving > dates and times to the database. I think I'll just hold up on the SVN for > now. At least until they update the API. > > On Dec 11, 2007 9:33 AM, Gwoo <[EMAIL PROTECTED]> wrote: > > > > > What does it say cleanUpFields() was replaced by? Maybe you could use > > that --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Saving Date and Time NOT in the Model/Database (cleanUpFields not working)
It says it was replaced by: Model::deconstruct() But the functionality is different. Doing a direct call didn't work for me. Even if it did, there's another issue with the latest version not saving dates and times to the database. I think I'll just hold up on the SVN for now. At least until they update the API. On Dec 11, 2007 9:33 AM, Gwoo <[EMAIL PROTECTED]> wrote: > > What does it say cleanUpFields() was replaced by? Maybe you could use > that > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Saving Date and Time NOT in the Model/Database (cleanUpFields not working)
Yeah, I saw that... And I also saw something that said this is called through Model::set(). But, I'm still lost as to how to use it. Also, what I did was I got the latest SVN and I just did a bake on a simple database with a date field. Long story short, it doesn't work. I think I'll just stick to 1.2 pre beta...but I want all the cool behavior stuff :( :( :( On Dec 11, 2007 10:48 AM, Samuel DeVore <[EMAIL PROTECTED]> wrote: > > Model::deconstruct() I think > > > http://api.cakephp.org/1.2/class_model.html#0198f3999e2942f8e82db80fc9e19c30 > > :) > > Sam D > > On Dec 11, 2007 8:33 AM, Gwoo <[EMAIL PROTECTED]> wrote: > > > > What does it say cleanUpFields() was replaced by? Maybe you could use > > that > > > > > > > > > > > -- > (the old fart) the advice is free, the lack of crankiness will cost you > > - its a fine line between a real question and an idiot > > http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/ > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Saving Date and Time NOT in the Model/Database (cleanUpFields not working)
Model::deconstruct() I think http://api.cakephp.org/1.2/class_model.html#0198f3999e2942f8e82db80fc9e19c30 :) Sam D On Dec 11, 2007 8:33 AM, Gwoo <[EMAIL PROTECTED]> wrote: > > What does it say cleanUpFields() was replaced by? Maybe you could use > that > > > > -- (the old fart) the advice is free, the lack of crankiness will cost you - its a fine line between a real question and an idiot http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Saving Date and Time NOT in the Model/Database (cleanUpFields not working)
What does it say cleanUpFields() was replaced by? Maybe you could use that --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Saving Date and Time NOT in the Model/Database (cleanUpFields not working)
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/ (aus format) to -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 cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options,
Re: Saving Date and Time NOT in the Model/Database (cleanUpFields not working)
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/ (aus format) to -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 cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Saving Date and Time NOT in the Model/Database (cleanUpFields not working)
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/ (aus format) to -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 cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Saving Date and Time NOT in the Model/Database (cleanUpFields not working)
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/ (aus format) to -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 cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Saving Date and Time NOT in the Model/Database (cleanUpFields not working)
Sorry AD, you've totally lost me. -- Baz L Web Development 2.0: Web Design, CakePHP, Javascript http://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/model.php#L871 > > 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 cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Saving Date and Time NOT in the Model/Database (cleanUpFields not working)
My thinking is if there's already a function there, maybe there's someway I can use it without doing my own. I'm tried concatinating the fields, but that didn't work so well (stuff like 1:02 am, for some reason becomes 1:2 am and then strtotime doesn't work). -- Baz L Web Development 2.0: Web Design, CakePHP, Javascript http://www.WebDevelopment2.com/ On Dec 5, 2007 4:29 AM, Adam Royle <[EMAIL PROTECTED]> wrote: > > Is it a big deal to not have them in the database? Maybe if I > understood the context a bit better then I might be able to suggest > something more appropriate. > > In my forms when I have datetime fields, I separate them off into two > fields - date as d/m/y and time as any string strtotime() handles. > > Then in my AppController I have overrided the cleanUpFields() and put > my own date logic in there, which converts my custom form elements to > a date string cakephp can handle. It is however tied in automatically > with the model definition like cakephp core is. It also sets the date > value to null if the field is blank. > > If you're not saving the data into a model, then maybe you can just > write a function that takes in the field name and returns the combined > date value, and put that in your appcontroller or something like that. > > Cheers, > Adam > > On Dec 5, 5:57 pm, 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? > > > > Ideas would be greatly appreciated. > > -- > > Baz L > > Web Development 2.0: Web Design, CakePHP, > Javascripthttp://www.WebDevelopment2.com/ > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Saving Date and Time NOT in the Model/Database (cleanUpFields not working)
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/model.php#L871 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 cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Saving Date and Time NOT in the Model/Database (cleanUpFields not working)
Is it a big deal to not have them in the database? Maybe if I understood the context a bit better then I might be able to suggest something more appropriate. In my forms when I have datetime fields, I separate them off into two fields - date as d/m/y and time as any string strtotime() handles. Then in my AppController I have overrided the cleanUpFields() and put my own date logic in there, which converts my custom form elements to a date string cakephp can handle. It is however tied in automatically with the model definition like cakephp core is. It also sets the date value to null if the field is blank. If you're not saving the data into a model, then maybe you can just write a function that takes in the field name and returns the combined date value, and put that in your appcontroller or something like that. Cheers, Adam On Dec 5, 5:57 pm, 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? > > Ideas would be greatly appreciated. > -- > Baz L > Web Development 2.0: Web Design, CakePHP, > Javascripthttp://www.WebDevelopment2.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Saving Date and Time NOT in the Model/Database (cleanUpFields not working)
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? Ideas would be greatly appreciated. -- Baz L Web Development 2.0: Web Design, CakePHP, Javascript http://www.WebDevelopment2.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---