<?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: Customising Symfony forms &#8211; be careful with base class inheritence</title>
	<atom:link href="http://eatmymonkeydust.com/2009/03/customising-symfony-forms-be-careful-with-base-class-inheritence/feed/" rel="self" type="application/rss+xml" />
	<link>http://eatmymonkeydust.com/2009/03/customising-symfony-forms-be-careful-with-base-class-inheritence/</link>
	<description>Life, PHP and Symfony - straight from the monkey's mouth</description>
	<lastBuildDate>Mon, 25 Jul 2011 10:23:41 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Marcelo</title>
		<link>http://eatmymonkeydust.com/2009/03/customising-symfony-forms-be-careful-with-base-class-inheritence/comment-page-1/#comment-957</link>
		<dc:creator>Marcelo</dc:creator>
		<pubDate>Tue, 30 Nov 2010 17:55:11 +0000</pubDate>
		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=92#comment-957</guid>
		<description>Hi Russ, I have a problem here not like you but has to do with forms and unset.

Situation: I have 3 embed forms, I&#039;m going to use just one, the other two will be unset through a select option. But if this form has required fields no filled in the validation page I will lose the unset embed forms but I still have my select options which won&#039;t work properly because the unset embed forms.

Do you have some idea ?</description>
		<content:encoded><![CDATA[<p>Hi Russ, I have a problem here not like you but has to do with forms and unset.</p>
<p>Situation: I have 3 embed forms, I&#8217;m going to use just one, the other two will be unset through a select option. But if this form has required fields no filled in the validation page I will lose the unset embed forms but I still have my select options which won&#8217;t work properly because the unset embed forms.</p>
<p>Do you have some idea ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Closer To The Ideal &#187; Blog Archive &#187; In Symfony, one&#8217;s validators must match the form inputs</title>
		<link>http://eatmymonkeydust.com/2009/03/customising-symfony-forms-be-careful-with-base-class-inheritence/comment-page-1/#comment-317</link>
		<dc:creator>Closer To The Ideal &#187; Blog Archive &#187; In Symfony, one&#8217;s validators must match the form inputs</dc:creator>
		<pubDate>Fri, 08 May 2009 01:17:30 +0000</pubDate>
		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=92#comment-317</guid>
		<description>[...] ran into this same problem, for which Symfony fails to offer a sensible error message:  It then occurred to me that the entire [...]</description>
		<content:encoded><![CDATA[<p>[...] ran into this same problem, for which Symfony fails to offer a sensible error message:  It then occurred to me that the entire [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joes</title>
		<link>http://eatmymonkeydust.com/2009/03/customising-symfony-forms-be-careful-with-base-class-inheritence/comment-page-1/#comment-290</link>
		<dc:creator>joes</dc:creator>
		<pubDate>Tue, 24 Mar 2009 08:12:48 +0000</pubDate>
		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=92#comment-290</guid>
		<description>This kind of method has already been proposed to symfony in http://trac.symfony-project.org/ticket/5525. Slightly different implementation, but very much the same thing...</description>
		<content:encoded><![CDATA[<p>This kind of method has already been proposed to symfony in <a href="http://trac.symfony-project.org/ticket/5525" rel="nofollow">http://trac.symfony-project.org/ticket/5525</a>. Slightly different implementation, but very much the same thing&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russ</title>
		<link>http://eatmymonkeydust.com/2009/03/customising-symfony-forms-be-careful-with-base-class-inheritence/comment-page-1/#comment-289</link>
		<dc:creator>Russ</dc:creator>
		<pubDate>Mon, 23 Mar 2009 20:06:25 +0000</pubDate>
		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=92#comment-289</guid>
		<description>Nice idea, maybe it&#039;s something that can be added to the core?

It would be better off in sfForm I guess... Have you submitted a patch?</description>
		<content:encoded><![CDATA[<p>Nice idea, maybe it&#8217;s something that can be added to the core?</p>
<p>It would be better off in sfForm I guess&#8230; Have you submitted a patch?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joes</title>
		<link>http://eatmymonkeydust.com/2009/03/customising-symfony-forms-be-careful-with-base-class-inheritence/comment-page-1/#comment-288</link>
		<dc:creator>joes</dc:creator>
		<pubDate>Mon, 23 Mar 2009 16:28:39 +0000</pubDate>
		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=92#comment-288</guid>
		<description>I&#039;ve had the same issue as you (wanting to keep only a few fields but not wanting to have many ugly unset:s in the code) so I stuck this method into BaseFormDoctrine:

/**
   * unsetAllFieldsExcept
   * 
   * Unsets all fields except for the ones defined in func_get_args
   *
   * @return void
   **/
  public function unsetAllFieldsExcept()
  {
    $keepFields = func_get_args();
    foreach($this as $key =&gt; $value) $baseFields[] = $key;
    $temp = array_diff($baseFields, $keepFields);
    foreach ($temp as $unsetField) unset($this[$unsetField]);
  }

Using the above method in this case would allow one to use only the &#039;amount&#039; and &#039;reduced_amount&#039; of the form by doing:

public function configure()
{
  $this-&gt;unsetAllFieldsExcept(&#039;amount&#039;, &#039;reduced_amount&#039;);
}</description>
		<content:encoded><![CDATA[<p>I&#8217;ve had the same issue as you (wanting to keep only a few fields but not wanting to have many ugly unset:s in the code) so I stuck this method into BaseFormDoctrine:</p>
<p>/**<br />
   * unsetAllFieldsExcept<br />
   *<br />
   * Unsets all fields except for the ones defined in func_get_args<br />
   *<br />
   * @return void<br />
   **/<br />
  public function unsetAllFieldsExcept()<br />
  {<br />
    $keepFields = func_get_args();<br />
    foreach($this as $key =&gt; $value) $baseFields[] = $key;<br />
    $temp = array_diff($baseFields, $keepFields);<br />
    foreach ($temp as $unsetField) unset($this[$unsetField]);<br />
  }</p>
<p>Using the above method in this case would allow one to use only the &#8216;amount&#8217; and &#8216;reduced_amount&#8217; of the form by doing:</p>
<p>public function configure()<br />
{<br />
  $this-&gt;unsetAllFieldsExcept(&#8216;amount&#8217;, &#8216;reduced_amount&#8217;);<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>

