<?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: Snippet: Symfony Forms &#8211; Setting Default Values</title>
	<atom:link href="http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values/feed" rel="self" type="application/rss+xml" />
	<link>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values</link>
	<description>Web development, Symfony, Wordpress and general geekery</description>
	<lastBuildDate>Wed, 28 Jul 2010 06:55:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Apul</title>
		<link>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values/comment-page-1#comment-671</link>
		<dc:creator>Apul</dc:creator>
		<pubDate>Fri, 18 Jun 2010 07:19:00 +0000</pubDate>
		<guid isPermaLink="false">http://erisds.co.uk/?p=97#comment-671</guid>
		<description>Yes. That&#039;s the thing.

Thanks.</description>
		<content:encoded><![CDATA[<p>Yes. That&#8217;s the thing.</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ErisDS</title>
		<link>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values/comment-page-1#comment-670</link>
		<dc:creator>ErisDS</dc:creator>
		<pubDate>Fri, 18 Jun 2010 07:06:35 +0000</pubDate>
		<guid isPermaLink="false">http://erisds.co.uk/?p=97#comment-670</guid>
		<description>@Apul You wouldn&#039;t (and can&#039;t as fas as I am aware) pass a &quot;default&quot; value from an action to a form. Either the form itself has a &quot;default&quot; value (and is set as shown in this Snippet) or the object passed to the form has a &quot;default&quot; value.

If you have values to assign to the form from your action, then you would set these on a relevant object, and then pass the object to the form as shown here:

&lt;code lang=&quot;php&quot;&gt;
&lt; ?php
    //apps/myApp/modules/myModule/actions/actions.class.php
   public function executeMyAction(sfWebRequest $request)
  {
    // create an object for the form
    $object = new MyObject();
   // object already has default values, or to set additional ones:
    $object-&gt;setValue(&#039;Default&#039;);
  // instantiate the new form with it&#039;s object
    $this-&gt;form = new MyObjectForm($object);
  }
?&gt;
&lt;/code&gt;

I hope this answers your question?</description>
		<content:encoded><![CDATA[<p>@Apul You wouldn&#8217;t (and can&#8217;t as fas as I am aware) pass a &#8220;default&#8221; value from an action to a form. Either the form itself has a &#8220;default&#8221; value (and is set as shown in this Snippet) or the object passed to the form has a &#8220;default&#8221; value.</p>
<p>If you have values to assign to the form from your action, then you would set these on a relevant object, and then pass the object to the form as shown here:</p>
<div class="codecolorer-container php twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//apps/myApp/modules/myModule/actions/actions.class.php</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> executeMyAction<span style="color: #009900;">&#40;</span>sfWebRequest <span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// create an object for the form</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$object</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// object already has default values, or to set additional ones:</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Default'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">// instantiate the new form with it's object</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyObjectForm<span style="color: #009900;">&#40;</span><span style="color: #000088;">$object</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<p>I hope this answers your question?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Apul</title>
		<link>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values/comment-page-1#comment-669</link>
		<dc:creator>Apul</dc:creator>
		<pubDate>Fri, 18 Jun 2010 05:40:55 +0000</pubDate>
		<guid isPermaLink="false">http://erisds.co.uk/?p=97#comment-669</guid>
		<description>But, How to pass these default values from action?</description>
		<content:encoded><![CDATA[<p>But, How to pass these default values from action?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ikon</title>
		<link>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values/comment-page-1#comment-531</link>
		<dc:creator>Ikon</dc:creator>
		<pubDate>Mon, 17 May 2010 08:10:58 +0000</pubDate>
		<guid isPermaLink="false">http://erisds.co.uk/?p=97#comment-531</guid>
		<description>Thank you!

I was totally depressed when trying to set the default value through the widgetschema, which should be fine but actually not. But setting the default value through the form is working perfectly.

More snippets like this pls! XD</description>
		<content:encoded><![CDATA[<p>Thank you!</p>
<p>I was totally depressed when trying to set the default value through the widgetschema, which should be fine but actually not. But setting the default value through the form is working perfectly.</p>
<p>More snippets like this pls! XD</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: atze</title>
		<link>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values/comment-page-1#comment-426</link>
		<dc:creator>atze</dc:creator>
		<pubDate>Thu, 17 Dec 2009 15:23:56 +0000</pubDate>
		<guid isPermaLink="false">http://erisds.co.uk/?p=97#comment-426</guid>
		<description>it&#039;s been a while, working with symfony - started digging in the widget-codes for default value etc... 
found your little snippet - voilá

thx alot, merry chistmas &amp; happy new year</description>
		<content:encoded><![CDATA[<p>it&#8217;s been a while, working with symfony &#8211; started digging in the widget-codes for default value etc&#8230;<br />
found your little snippet &#8211; voilá</p>
<p>thx alot, merry chistmas &amp; happy new year</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pedro Casado</title>
		<link>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values/comment-page-1#comment-408</link>
		<dc:creator>Pedro Casado</dc:creator>
		<pubDate>Fri, 30 Oct 2009 00:15:11 +0000</pubDate>
		<guid isPermaLink="false">http://erisds.co.uk/?p=97#comment-408</guid>
		<description>Cool! I like snippets like these ;D</description>
		<content:encoded><![CDATA[<p>Cool! I like snippets like these ;D</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dratir</title>
		<link>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values/comment-page-1#comment-308</link>
		<dc:creator>Dratir</dc:creator>
		<pubDate>Fri, 07 Aug 2009 19:22:46 +0000</pubDate>
		<guid isPermaLink="false">http://erisds.co.uk/?p=97#comment-308</guid>
		<description>Another possibility is to set the default value in the schema. However, I think its prefferable to set it in the Form rather than changing the Database every time ;)</description>
		<content:encoded><![CDATA[<p>Another possibility is to set the default value in the schema. However, I think its prefferable to set it in the Form rather than changing the Database every time ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ErisDS</title>
		<link>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values/comment-page-1#comment-83</link>
		<dc:creator>ErisDS</dc:creator>
		<pubDate>Mon, 08 Jun 2009 20:52:29 +0000</pubDate>
		<guid isPermaLink="false">http://erisds.co.uk/?p=97#comment-83</guid>
		<description>You&#039;re very welcome :)</description>
		<content:encoded><![CDATA[<p>You&#8217;re very welcome :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values/comment-page-1#comment-80</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Thu, 04 Jun 2009 14:27:44 +0000</pubDate>
		<guid isPermaLink="false">http://erisds.co.uk/?p=97#comment-80</guid>
		<description>Thank you - just what I needed</description>
		<content:encoded><![CDATA[<p>Thank you &#8211; just what I needed</p>
]]></content:encoded>
	</item>
</channel>
</rss>
