<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Another use case for beforeSave()</title>
	<atom:link href="http://cakebaker.42dh.com/2006/01/20/another-use-case-for-beforesave/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2006/01/20/another-use-case-for-beforesave/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 31 Jan 2012 15:12:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Ricardo Stuven</title>
		<link>http://cakebaker.42dh.com/2006/01/20/another-use-case-for-beforesave/comment-page-1/#comment-129</link>
		<dc:creator>Ricardo Stuven</dc:creator>
		<pubDate>Sat, 28 Jan 2006 21:37:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=69#comment-129</guid>
		<description>FYI, here is andrew&#039;s ticket:
https://trac.cakephp.org/ticket/329</description>
		<content:encoded><![CDATA[<p>FYI, here is andrew&#8217;s ticket:<br />
<a href="https://trac.cakephp.org/ticket/329" rel="nofollow">https://trac.cakephp.org/ticket/329</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andrew</title>
		<link>http://cakebaker.42dh.com/2006/01/20/another-use-case-for-beforesave/comment-page-1/#comment-128</link>
		<dc:creator>andrew</dc:creator>
		<pubDate>Thu, 26 Jan 2006 16:49:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=69#comment-128</guid>
		<description>This is a problem with the HtmlHelper class. The checkbox should recieve on and off values (ex. array(&#039;on&#039;=&gt;1, &#039;off&#039;=&gt;0) ). Then an input type=&quot;hidden&quot; with the same name as the checkbox and the default off value should be printed just before the checkbox input.

If the checkbox is checked the &#039;on&#039; value is returned, if it is not check the hidden value is returned.</description>
		<content:encoded><![CDATA[<p>This is a problem with the HtmlHelper class. The checkbox should recieve on and off values (ex. array(&#8216;on&#8217;=&gt;1, &#8216;off&#8217;=&gt;0) ). Then an input type=&#8221;hidden&#8221; with the same name as the checkbox and the default off value should be printed just before the checkbox input.</p>
<p>If the checkbox is checked the &#8216;on&#8217; value is returned, if it is not check the hidden value is returned.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ricardo Stuven</title>
		<link>http://cakebaker.42dh.com/2006/01/20/another-use-case-for-beforesave/comment-page-1/#comment-127</link>
		<dc:creator>Ricardo Stuven</dc:creator>
		<pubDate>Wed, 25 Jan 2006 00:56:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=69#comment-127</guid>
		<description>The FAQ is now updated.</description>
		<content:encoded><![CDATA[<p>The FAQ is now updated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cake baker &#187; Two useful functions for your AppModel</title>
		<link>http://cakebaker.42dh.com/2006/01/20/another-use-case-for-beforesave/comment-page-1/#comment-126</link>
		<dc:creator>cake baker &#187; Two useful functions for your AppModel</dc:creator>
		<pubDate>Mon, 23 Jan 2006 10:20:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=69#comment-126</guid>
		<description>[...] Ricardo Stuven&#8217;s comment inspired me to completely refactor a function described in an earlier post. So from now on my app model contains two functions: setBoolean and setDate. [...]</description>
		<content:encoded><![CDATA[<p>[...] Ricardo Stuven&#8217;s comment inspired me to completely refactor a function described in an earlier post. So from now on my app model contains two functions: setBoolean and setDate. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2006/01/20/another-use-case-for-beforesave/comment-page-1/#comment-125</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Mon, 23 Jan 2006 07:58:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=69#comment-125</guid>
		<description>@Ricardo: thank you for this nice and reusable solution :)</description>
		<content:encoded><![CDATA[<p>@Ricardo: thank you for this nice and reusable solution :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ricardo Stuven</title>
		<link>http://cakebaker.42dh.com/2006/01/20/another-use-case-for-beforesave/comment-page-1/#comment-124</link>
		<dc:creator>Ricardo Stuven</dc:creator>
		<pubDate>Mon, 23 Jan 2006 06:58:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=69#comment-124</guid>
		<description>Add this to your AppModel:

&lt;code&gt;
function setBoolean($field)
{
  $this-&gt;data[$this-&gt;name][$field] = isset($this-&gt;data[$this-&gt;name][$field])?1:0;
}
&lt;/code&gt;

Now your code looks like this:

&lt;code&gt;
function beforeSave()
{
  $this-&gt;setBoolean(&#039;public&#039;);
  return true;
}
&lt;/code&gt;

:-)</description>
		<content:encoded><![CDATA[<p>Add this to your AppModel:</p>
<pre><code>function setBoolean($field)
{
  $this-&amp;gt;data[$this-&amp;gt;name][$field] = isset($this-&amp;gt;data[$this-&amp;gt;name][$field])?1:0;
}</code></pre>
<p>Now your code looks like this:</p>
<pre><code>function beforeSave()
{
  $this-&amp;gt;setBoolean('public');
  return true;
}</code></pre>
<p>:-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2006/01/20/another-use-case-for-beforesave/comment-page-1/#comment-123</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Sat, 21 Jan 2006 12:45:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=69#comment-123</guid>
		<description>Well, you can solve it with some Javascript and a hidden field. But that has the disadvantage that it does not work when Javascript is disabled.</description>
		<content:encoded><![CDATA[<p>Well, you can solve it with some Javascript and a hidden field. But that has the disadvantage that it does not work when Javascript is disabled.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mememe</title>
		<link>http://cakebaker.42dh.com/2006/01/20/another-use-case-for-beforesave/comment-page-1/#comment-122</link>
		<dc:creator>mememe</dc:creator>
		<pubDate>Sat, 21 Jan 2006 02:20:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=69#comment-122</guid>
		<description>the model could be a better place than controller, but i think the right place should be the *view* because it&#039;s an issue with the checkbox, not with data type. excuse i don&#039;t know how to solve it, but i think this should be the proper thing...</description>
		<content:encoded><![CDATA[<p>the model could be a better place than controller, but i think the right place should be the *view* because it&#8217;s an issue with the checkbox, not with data type. excuse i don&#8217;t know how to solve it, but i think this should be the proper thing&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

