{"id":44,"date":"2008-06-05T11:46:38","date_gmt":"2008-06-05T16:46:38","guid":{"rendered":"http:\/\/osric.com\/chris\/accidental-developer\/?p=44"},"modified":"2008-06-05T11:46:41","modified_gmt":"2008-06-05T16:46:41","slug":"cake-cleanupfields","status":"publish","type":"post","link":"https:\/\/osric.com\/chris\/accidental-developer\/2008\/06\/cake-cleanupfields\/","title":{"rendered":"Cake CleanUpFields"},"content":{"rendered":"<p>Yesterday night I managed to get stuck on my cake project it two separate places, which is sort of amazing since I have only been stuck with cake once other than that on this project. (To Be fair, One of the problems is with Plesk, may it&#8217;s name be damn for a thousand years, not cake)<\/p>\n<p>Anyway, I just solved the other problem thanks to the comments on <a href=\"http:\/\/shabadeehoob.com\/2007\/02\/10\/cakephp-saving-dates-in-your-model\/\">this<\/a> post, and I thought I would share.<\/p>\n<p>When you cuse cake&#8217;s helper to pick a date\/time it builds a whole lot of sub-fields. Then when cleanUpFields is called it stitches them all back together into one date time. However, it&#8217;s a little too smart for its own good, it only stitches them back together if it knows about the date-time, and it only knows about the date-time if that field is in the primary model for the controller your working with. This means that if you are using a second model , it wont fix the date-times.<\/p>\n<p>The good news is that their is a work-around for that, you can simply call cleanUpFields again, with the second, or third model name as a param. (I.E. $this-&gt;cleanUpFields(&#8216;payments&#8217;); )<\/p>\n<p>What I haven&#8217;t found a work around for however, is if you want to get a date that doesn&#8217;t belong to a model at all. hopefully I will stumble on an answer as I continue with this, If I do I&#8217;ll post it in the comments. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday night I managed to get stuck on my cake project it two separate places, which is sort of amazing since I have only been stuck with cake once other than that on this project. (To Be fair, One of the problems is with Plesk, may it&#8217;s name be damn for a thousand years, not &hellip; <a href=\"https:\/\/osric.com\/chris\/accidental-developer\/2008\/06\/cake-cleanupfields\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Cake CleanUpFields<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-44","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/44","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/comments?post=44"}],"version-history":[{"count":0,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/44\/revisions"}],"wp:attachment":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/media?parent=44"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/categories?post=44"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/tags?post=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}