Re: Auto-fill Date Values In Form
Thanks Cricket, I tried the lot, debugging $this-data as well, but even when it wasn't selecting the date from $this-data the form would still save correctly - so the field had to have been correct. Oh well, hopefully it's never an issue again. It's only a few more lines of code than I would have liked. Adam Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Auto-fill Date Values In Form
On Fri, Nov 5, 2010 at 12:33 AM, Adam adamcbre...@gmail.com wrote: Thanks Paul, I really wanted it in a standard, form-helper format - - MM - DD drop-downs. I spent more time on it than i wanted to so in the end I just exploded the date value from the DB and manually assigned them each to day, month and year form-inputs with their set values. Like I said before, this has never been a problem for me in the past, but It was with code that someone else had built before me, so maybe I'll use that as an excuse ; ) I just tested in 1.3.5 and it worked fine: echo $this-Form-dateTime('Site.created', 'YMD'); Note what the docs say: http://book.cakephp.org/view/1418/dateTime dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $selected = null, $attributes = array()) You also can pre-select the current datetime by setting $selected = null and $attributes = array(empty = false) You can see, above, that I did pass null for the $selected param. However, I did not pass false for 'empty'. Perhaps your problem lies there. No, wait. If I do: echo $this-Form-dateTime('Site.created', 'YMD', '24', null, array()); ... I still get the value from the DB. Change that to: echo $this-Form-dateTime('Site.created', 'YMD', '24', null, array('empty' = false)); ... of course, I still get the correct value, because it's set. Are you certain that you're using the correct field, and that it definitely has a value? DO a debug($this-data) in your form view to be sure. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Auto-fill Date Values In Form
Exactly how are you wanting the date field to appear in the form? text field, split into select fields etc. The form helper should do all this for you. You may also find this bakery article of interest: http://bakery.cakephp.org/articles/mmanning/2008/04/12/using-the-unobtrusive-date-picker-widget-in-cakephp HTH, Paul Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Auto-fill Date Values In Form
Thanks Paul, I really wanted it in a standard, form-helper format - - MM - DD drop-downs. I spent more time on it than i wanted to so in the end I just exploded the date value from the DB and manually assigned them each to day, month and year form-inputs with their set values. Like I said before, this has never been a problem for me in the past, but It was with code that someone else had built before me, so maybe I'll use that as an excuse ; ) On Nov 4, 4:18 pm, WebbedIT p...@webbedit.co.uk wrote: Exactly how are you wanting the date field to appear in the form? text field, split into select fields etc. The form helper should do all this for you. You may also find this bakery article of interest:http://bakery.cakephp.org/articles/mmanning/2008/04/12/using-the-unob... HTH, Paul Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Auto-fill Date Values In Form
I'm having trouble auto-filling the form input with the date value that's already been saved in the database. Simply, I've saved a selected date, but when I return to edit it, the date defaults to today's date. I've never had a problem with the auto-filling forms before, but for some reason this won't work. Does anyone have any suggestions how to extract the D, M Y values out of a date string using Cake i.e. $job['Job']['date']['month'] etc.? I was thinking I could make my own separate inputs for each day, month and year... Thanks, Adam Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en