<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ramblings &#187; forms</title>
	<atom:link href="http://techore.com/tag/forms/feed/" rel="self" type="application/rss+xml" />
	<link>http://techore.com</link>
	<description>come to your own conclusions</description>
	<lastBuildDate>Mon, 30 Aug 2010 15:08:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>quickie: setting symfony datetime default</title>
		<link>http://techore.com/2010/01/quickie-setting-symfony-datetime-default/</link>
		<comments>http://techore.com/2010/01/quickie-setting-symfony-datetime-default/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 20:23:23 +0000</pubDate>
		<dc:creator>Patrick</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[fields]]></category>
		<category><![CDATA[form fields]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[quickie]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://techore.com/wp/?p=243</guid>
		<description><![CDATA[Setting the default value for a symfony form field is one of those tasks so simple that it's impossible to find out how to do it without a good bit of trial and error.  So without further ado, here is how to set a DateTime field's default value:
$this->widgetSchema['start_time']->setDefault(date("m/d/Y", now()));]]></description>
			<content:encoded><![CDATA[<p>Setting the default value for a symfony form field is one of those tasks so simple that it&#8217;s impossible to find out how to do it without a good bit of trial and error.  So without further ado, here is how to set a DateTime field&#8217;s default value:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">widgetSchema</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'start_time'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setDefault</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;m/d/Y&quot;</span><span style="color: #339933;">,</span> now<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Till Next Time</p>
]]></content:encoded>
			<wfw:commentRss>http://techore.com/2010/01/quickie-setting-symfony-datetime-default/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>updating symfony form values after submitting</title>
		<link>http://techore.com/2010/01/updating-symfony-form-values-after-submitting/</link>
		<comments>http://techore.com/2010/01/updating-symfony-form-values-after-submitting/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 21:46:36 +0000</pubDate>
		<dc:creator>Patrick</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[form update]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sfForms]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://techore.com/wp/?p=240</guid>
		<description><![CDATA[One thing that's made programming on symfony very aggravating has been dealing with the forms.  Some sections of the forms are not well documented.  The main issue that I have with this at work is that we deal with GPS coordinates and the users enter their coordinates in degree-minute-seconds format but the database saves them in degree-decimal format.]]></description>
			<content:encoded><![CDATA[<p>One thing that&#8217;s made programming on symfony very aggravating has been dealing with the forms.  Some sections of the forms are not well documented.  The main issue that I have with this at work is that we deal with GPS coordinates and the users enter their coordinates in degree-minute-seconds format but the database saves them in degree-decimal format.</p>
<p>I had googled for a solution to this problem before, but had not found anything to guide me to the answer.  The couple answers I had found were not very clear on getting it to work.  Till I found <a title="jamescharlesworth.com" href="http://bit.ly/5YpPpu" target="_blank">this</a>.  Following these guidelines I got it to work on a test deployment of symfony.  Code below:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Blog <span style="color: #000000; font-weight: bold;">extends</span> BaseBlog <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Initializes internal state of Blog object.
	 * @see        parent::__construct()
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Make sure that parent constructor is always invoked, since that</span>
		<span style="color: #666666; font-style: italic;">// is where any default values for this object are set.</span>
		parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">/*
	 * this function overrides the BaseBlog::save function to allow
	 * changes to be made to the object before saving to the database
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> save<span style="color: #009900;">&#40;</span>PropelPDO <span style="color: #000088;">$con</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCommentCount</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'11'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> parent<span style="color: #339933;">::</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Till Next Time</p>
]]></content:encoded>
			<wfw:commentRss>http://techore.com/2010/01/updating-symfony-form-values-after-submitting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding javascript to symfony form field</title>
		<link>http://techore.com/2009/11/adding-javascript-to-symfony-form-field/</link>
		<comments>http://techore.com/2009/11/adding-javascript-to-symfony-form-field/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 21:27:25 +0000</pubDate>
		<dc:creator>Patrick</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[onchange]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sfWidget]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[widgets]]></category>

		<guid isPermaLink="false">http://techore.com/wp/?p=194</guid>
		<description><![CDATA[In the users table at my company's website there are fields for company, division, region, and location.  Since each level of the company organization affects all the lower categories I have to filter out the invalid choices when a higher level choice is selected.]]></description>
			<content:encoded><![CDATA[<p>In the users table at my company&#8217;s website there are fields for company, division, region, and location.  Since each level of the company organization affects all the lower categories I have to filter out the invalid choices when a higher level choice is selected.</p>
<p>I&#8217;ve implemented this on some forms that I&#8217;ve created manually on the site but not in any forms that I haven&#8217;t heavily modified from the stock symfony creation.  I started googling around to find a solution but could not find a simple explanation of how to do it.  I expected to find at least some information in one of symfony&#8217;s otherwise excellent tutorials, but alas, no.</p>
<p>I had a minor epiphany and went digging through the forms API that symfony provides and realized that I should easily be able to do this through the sfWidgetFormPropelChoice method.  The second parameter passed is the html attributes for the form field.  I thought I had seen a form post <a title="symfony forum" href="http://bit.ly/3f9j24" target="_blank">here</a> that said that I could add javascript code to the html attributes and not have it get converted into html entities.</p>
<p>I tried throwing a simple alert() inside the onchange attribute for my company box and wham! it worked!  So simple.  Code below:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">new</span> sfWidgetFormPropelChoice<span style="color: #009900;">&#40;</span>
	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'model'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Company'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'add_empty'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'onchange'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;filterBy('company', 'division', this.value, 'sf_guard_user_user_division_id');&quot;</span> <span style="color: #339933;">.</span>
			<span style="color: #0000ff;">&quot;filterBy('company', 'region', this.value, 'sf_guard_user_user_region_id');&quot;</span> <span style="color: #339933;">.</span>
			<span style="color: #0000ff;">&quot;filterBy('company', 'location', this.value, 'sf_guard_user_user_location_id');&quot;</span>
	<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span></pre></div></div>

<p>Till Next Time</p>
]]></content:encoded>
			<wfw:commentRss>http://techore.com/2009/11/adding-javascript-to-symfony-form-field/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
