<?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>David&#039;s virtual world</title>
	<atom:link href="http://blog.vworld.at/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.vworld.at</link>
	<description>Software development and software quality</description>
	<lastBuildDate>Fri, 02 Sep 2011 13:39:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Releasing cool symfony plugins on github</title>
		<link>http://blog.vworld.at/2011/09/02/releasing-cool-symfony-plugins-on-github/</link>
		<comments>http://blog.vworld.at/2011/09/02/releasing-cool-symfony-plugins-on-github/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 13:36:03 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://blog.vworld.at/?p=252</guid>
		<description><![CDATA[It&#8217;s been a long time since my last post and probably an even longer felt waiting time for those of you dear readers waiting for code. But wait no more, and check out 3 fresh plugins on my github: weUniversalClassLoaderPlugin Want to use an Sf2 component or any other namespaced PHP code in your sf1 [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a long time since my last post and probably an even longer felt waiting time for those of you dear readers waiting for code. But wait no more, and check out 3 fresh plugins on <a href="https://github.com/vworldat/" title="my github">my github</a>:</p>
<h3>weUniversalClassLoaderPlugin</h3>
<p>Want to use an Sf2 component or any other namespaced PHP code in your sf1 project? Use this plugin to make it work automatically.<br />
<a href="https://github.com/vworldat/weUniversalClassLoaderPlugin" title="weUniversalClassLoaderPlugin">weUniversalClassLoaderPlugin</a></p>
<h3>weGlobalConfigPlugin</h3>
<p>A custom config handler to bypass the crowded app.yml with some nice bonus. Not mandatory but useful!<br />
<a href="https://github.com/vworldat/weGlobalConfigPlugin" title="weGlobalConfigPlugin">weGlobalConfigPlugin</a></p>
<h3>weErrorHandlerPlugin</h3>
<p>Tired of finding out where that damn &#8220;Notice in file xy.php on line 1234&#8243; comes from? Make it an exception and view the stack trace!<br />
Sick of crappy php libraries (oh yes, php_ldap, this one goes to you) that use warnings and notices instead of exceptions? This is the past, baby, welcome to the 21st century!<br />
<a href="https://github.com/vworldat/weErrorHandlerPlugin" title="weErrorHandlerPlugin">weErrorHandlerPlugin</a></p>
<h3>What&#8217;s the status, actually?</h3>
<p>All the code comes as-it-is, this means:</p>
<ul>
<li>No (unit) tests</li>
<li>Not all the functions are documented well</li>
</ul>
<p>This shouldn&#8217;t keep you from trying it, since the usage READMEs are helpful and the code is mostly self-explaining. If you have any questions, don&#8217;t bother to ask them (probably by opening github tickets). </p>
<p>If you want to help (e.g. by writing tests, documentation, better code), feel free to fork and pull-request. It&#8217;s all about the code nowadays!</p>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vworld.at/2011/09/02/releasing-cool-symfony-plugins-on-github/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Attending symfony day 2010 in Cologne</title>
		<link>http://blog.vworld.at/2010/10/08/attending-symfony-day-2010-in-cologne/</link>
		<comments>http://blog.vworld.at/2010/10/08/attending-symfony-day-2010-in-cologne/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 06:51:48 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[symfony]]></category>
		<category><![CDATA[conference]]></category>

		<guid isPermaLink="false">http://blog.vworld.at/?p=248</guid>
		<description><![CDATA[I arrived at Cologne yesterday evening and I&#8217;m looking forward to some interesting sessions on symfony and of course Symfony2. By the way, Cologne looks like a nice city, there&#8217;s lots of evening activity even during the week.]]></description>
			<content:encoded><![CDATA[<p>I arrived at Cologne yesterday evening and I&#8217;m looking forward to some interesting sessions on symfony and of course Symfony2. By the way, Cologne looks like a nice city, there&#8217;s lots of evening activity even during the week.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vworld.at/2010/10/08/attending-symfony-day-2010-in-cologne/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What to do when symfony cli colorization does not work on unix systems</title>
		<link>http://blog.vworld.at/2010/02/21/what-to-do-when-symfony-cli-colorization-does-not-work-on-unix-systems/</link>
		<comments>http://blog.vworld.at/2010/02/21/what-to-do-when-symfony-cli-colorization-does-not-work-on-unix-systems/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 13:03:57 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[command-line]]></category>
		<category><![CDATA[documentation]]></category>

		<guid isPermaLink="false">http://blog.vworld.at/?p=216</guid>
		<description><![CDATA[I recently ran into an interesting problem: symfony wouldn&#8217;t colorize the command-line output on any recently installed openSUSE (11.2) system. At first I was totally at a loss, but after diving into the code base and doing some debugging I finally found the core of the problem: the posix PHP extension was not installed. So [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.vworld.at/wp-content/uploads/sf-cli.png" alt="symfony CLI" title="sf-cli" width="138" height="141" class="alignright size-full wp-image-224" style="padding-left: 10px" />I recently ran into an interesting problem: symfony wouldn&#8217;t colorize the command-line output on any recently installed openSUSE (11.2) system. At first I was totally at a loss, but after diving into the code base and doing some debugging I finally found the core of the problem: the posix PHP extension was not installed.</p>
<p>So if any of you experience a similar issue, check if the extension is present and loaded. On openSUSE systems it&#8217;s enough to install the php5-posix package. Looks like the package maintainers start to leave out stuff that hardly anyone uses anymore, which is basically a good thing. It just caught me on the wrong foot <img src='http://blog.vworld.at/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I <a href="http://trac.symfony-project.org/ticket/8312">filed a ticket</a> to include this in the symfony installation documentation because i couldn&#8217;t find it mentioned anywhere.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vworld.at/2010/02/21/what-to-do-when-symfony-cli-colorization-does-not-work-on-unix-systems/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Symfony Live 2010 review</title>
		<link>http://blog.vworld.at/2010/02/21/symfony-live-2010-review/</link>
		<comments>http://blog.vworld.at/2010/02/21/symfony-live-2010-review/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 22:00:28 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[Open source]]></category>

		<guid isPermaLink="false">http://blog.vworld.at/?p=200</guid>
		<description><![CDATA[The conference is over, I&#8217;m back in Vienna since Thursday evening and life has gone back to everyday normal. The city of Paris was quite interesting, I especially liked the broad architectural scope. Unfortunately I didn&#8217;t have much time for sightseeing. But let&#8217;s get back to why I was there, the symfony Live 2010 conference! [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.vworld.at/wp-content/uploads/sf-live.png" alt="Symfony Live" title="symfony live" width="150" height="149" class="alignright size-full wp-image-213" />The conference is over, I&#8217;m back in Vienna since Thursday evening and life has gone back to everyday normal. The city of Paris was quite interesting, I especially liked the broad architectural scope. Unfortunately I didn&#8217;t have much time for sightseeing. But let&#8217;s get back to why I was there, the <a href="http://www.symfony-live.com/">symfony Live 2010</a> conference!</p>
<h3>What was not so good</h3>
<p>Altogether I liked most talks, even the infamous Microsoft one, because each single talk provided knowledge I didn&#8217;t have before. There are some general issues I want to address though:</p>
<ul>
<li>Some speakers had a really bad French accent. I&#8217;m glad my English was good enough so I was able to follow all of them nevertheless, but for some listeners it must have been really hard.</li>
<li>Please please please provide portable headset microphones at future conferences. Speakers having to hold a microphone in their hands just look awkward, and it limits their freedom of movement and gestures. I mean, it&#8217;s not like headset mikes were ultra-future technology&#8230; This would also fix the &#8220;speaker A is much louder than speaker B because he holds the microphone too close&#8221; issue.</li>
<li>The Wi-Fi connection was really bad on the first day, but it was acceptable on the second. Looks like someone didn&#8217;t realize on time that there&#8217;d be hundreds of nerds with laptops present.</li>
<li>Please provide some way to get cola at future conferences, caffeine addicts will thank you for this, especially through the afternoon sessions <img src='http://blog.vworld.at/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
<li>The only speaker I really disliked was the second guy from the Microsoft team. If I want to be shouted at like that, I&#8217;ll visit a boot camp and insult some drill instructor, not attend a software conference!</li>
</ul>
<p>As said above the content of the talks was fine, although there were ups and downs of course. What was much more annoying was that some speakers seemingly didn&#8217;t know much about presenting stuff. This is of course acceptable for hacking nerds in general, but only until they have to speak at conferences. Please, guys, read some books about presentation techniques in advance before giving your next speech!</p>
<h3>What was great</h3>
<p>Let&#8217;s stop talking about failures and continue with things that require mentioning because they were great.</p>
<ul>
<li>The overall organization was cool and professional. If there were any troubles behind the scenes they were kept hidden from the audience, which is fine.</li>
<li>The food was good.</li>
<li>The twitter visualization on the big screen was a really cool thing to do.</li>
<li>The selection of talks was OK. It addressed both symfony newcomers and experienced listeners.</li>
<li>The truly outstanding speakers worth mentioning were in my opinion (in order of schedule):
<ul>
<li>John Cleveley: this talk set the bar for the first day. Clearly audible, great presentation, interesting content!</li>
<li>Jonathan Wage: obviously an experienced speaker too, with lots of detailed knowledge</li>
<li>Stefan Koopmanschap: although the session didn&#8217;t provide much new information for me it was nice to listen to. He knows how to handle crowds.</li>
<li>Lukas Kahwe Smith: unlike his companion (don&#8217;t remember the name) he was cool, professional and easy to understand.</li>
<li>Scott Chacon: that&#8217;s what a presentation has to be like. Just like that. The reference for the second day, which was altogether definitely better than the first one.</li>
<li>Fabien Potencier: Fabien knows how to savor his fame in situations like this and he has every right to do so! What he does and how he convinces people to follow his lead is just outstanding. Standing ovations for one of the most inspiring web developers nowadays!</li>
</ul>
</li>
</ul>
<p>Symfony Live 2010 was a huge gain for myself. I met lots of interesting people and collected tons of first-hand information. Since it was the first (but definitely not the last) symfony or PHP conference I attended, future events will show how it compares.</p>
<h3>Symfony 2 and the future</h3>
<p>Symfony 2 will be awesome. I also checked out the <a href="http://symfony-reloaded.org/">brand-new Symfony 2 web page</a>, which I recommend to everyone who is interested in PHP applications or frameworks.</p>
<p>It looks like <a href="http://www.phpbb.com/">phpBB</a> 4 will be built upon Symfony 2, which I personally really appreciate because phpBB was my stepladder into PHP development and the open source community around 2001. After switching to PHP5 and OOP style programming I started to disapprove of the phpBB development style. Hopefully there will be a turn around towards more best practices in the future!</p>
<h3>Before I forget it&#8230; the user stories</h3>
<p>On the first day Stefan Koopmanschap announced that symfony needs more people writing success stories helping others arguing in favor of symfony. Every publishable story provided until the end of the second day would win a set of symfony books. I couldn&#8217;t resist this offer and sat through the late evening in my hotel room hurting my fingers by typing on my netbook keyboard for 4 full hours. Since I had filed similar content as my speaker&#8217;s submission (which was unfortunately rejected) I knew there was enough interesting stuff to write about. It was worth the effort: I got 3 symfony books. Thanks to the symfony team!</p>
<p>I don&#8217;t know when my story will be published, but I&#8217;ll link it as soon as it is. The title is &#8220;Running a TV station with symfony&#8221;.</p>
<h3>Last but not least</h3>
<p><a href="http://www.devexp.eu/mr-t/">Toni</a>, I really would have liked meeting you, but it seems we just weren&#8217;t able to find each other. Let&#8217;s hope it will work next time <img src='http://blog.vworld.at/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>&lt;off-topic&gt; why is my WordPress editor so damn slow recently? &lt;/off-topic&gt;</p>
<p>Update 2010-03-17: <a href="http://www.symfony-project.org/blog/2010/03/17/running-a-tv-station-with-symfony">Running a TV station with symfony</a> was published on the symfony blog today.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vworld.at/2010/02/21/symfony-live-2010-review/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Symfony Live 2010 has started</title>
		<link>http://blog.vworld.at/2010/02/16/symfony-live-2010-has-started/</link>
		<comments>http://blog.vworld.at/2010/02/16/symfony-live-2010-has-started/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 14:15:35 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[conference]]></category>

		<guid isPermaLink="false">http://blog.vworld.at/?p=196</guid>
		<description><![CDATA[Today Symfony Live 2010 has started. There have already been some interesting sessions, but the WiFi connection is awfully slow or even down most of the time.]]></description>
			<content:encoded><![CDATA[<p>Today <a href="http://www.symfony-live.com/">Symfony Live 2010</a> has started. There have already been some interesting sessions, but the WiFi connection is awfully slow or even down most of the time.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vworld.at/2010/02/16/symfony-live-2010-has-started/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;ll be attending Symfony Live 2010</title>
		<link>http://blog.vworld.at/2009/09/29/ill-be-attending-symfony-live-2010/</link>
		<comments>http://blog.vworld.at/2009/09/29/ill-be-attending-symfony-live-2010/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 15:05:48 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[conference]]></category>

		<guid isPermaLink="false">http://blog.vworld.at/?p=184</guid>
		<description><![CDATA[Today I registered for the Symfony Live 2010 conference which will take place in Paris in February 2010. I&#8217;m looking forward to meeting lots of interesting people there!]]></description>
			<content:encoded><![CDATA[<p>Today I registered for the <a href="http://www.symfony-live.com/">Symfony Live 2010 conference</a> which will take place in Paris in February 2010. I&#8217;m looking forward to meeting lots of interesting people there!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vworld.at/2009/09/29/ill-be-attending-symfony-live-2010/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Support symfony at the SourceForge.net Community Choice Awards 2009</title>
		<link>http://blog.vworld.at/2009/05/14/support-symfony-at-the-sourceforgenet-community-choice-awards-2009/</link>
		<comments>http://blog.vworld.at/2009/05/14/support-symfony-at-the-sourceforgenet-community-choice-awards-2009/#comments</comments>
		<pubDate>Thu, 14 May 2009 10:47:46 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[web2.0]]></category>

		<guid isPermaLink="false">http://blog.vworld.at/?p=179</guid>
		<description><![CDATA[The SourceForge.net Community Choice Awards are on again and it&#8217;s time to nominate the greatest rapid application development PHP framework: symfony! I&#8217;ve nominated symfony in 3 categories: Best Tool or Utility for Developers Best Project Best Commercial Open Source Project Click the picture to nominate symfony too! Of course don&#8217;t forget to read and follow [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://sourceforge.net/community/cca09/">SourceForge.net Community Choice Awards</a> are on again and it&#8217;s time to nominate the greatest rapid application development PHP framework: symfony!</p>
<p>I&#8217;ve nominated symfony in 3 categories:</p>
<ul>
<li>Best Tool or Utility for Developers</li>
<li>Best Project</li>
<li>Best Commercial Open Source Project</li>
</ul>
<p>Click the picture to nominate symfony too! Of course don&#8217;t forget to <strong>read and follow the nomination rules to allow for a fair voting process</strong>!<br />
<a href="http://sourceforge.net/community/cca09/nominate/?project_name=symfony PHP framework&#038;project_url=http://www.symfony-project.org/"><img src="http://sourceforge.net/images/cca/cca_nominate.png" border="0"/></a></p>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vworld.at/2009/05/14/support-symfony-at-the-sourceforgenet-community-choice-awards-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TiddlyWiki &#8211; a JavaScript only Wiki engine</title>
		<link>http://blog.vworld.at/2009/04/20/tiddlywiki-a-javascript-only-wiki-engine/</link>
		<comments>http://blog.vworld.at/2009/04/20/tiddlywiki-a-javascript-only-wiki-engine/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 09:35:49 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[web2.0]]></category>
		<category><![CDATA[Wiki]]></category>

		<guid isPermaLink="false">http://blog.vworld.at/?p=175</guid>
		<description><![CDATA[Today I stumbled upon a JavaScript Wiki engine called TiddlyWiki. It consists of a single HTML file using JQuery to modify itself. There&#8217;s also a good documentation MediaWiki on tiddlywiki.org. TiddlyWiki has a plugin system where you can attach customization JavaScript allowing for various new features. It even provides an auto update mechanism allowing to [...]]]></description>
			<content:encoded><![CDATA[<p>Today I stumbled upon a JavaScript Wiki engine called <a href="http://tiddlywiki.com/">TiddlyWiki</a>. It consists of a single HTML file using JQuery to modify itself. There&#8217;s also a good documentation MediaWiki on <a href="http://tiddlywiki.org/wiki/Main_Page">tiddlywiki.org</a>. TiddlyWiki has a plugin system where you can attach customization JavaScript allowing for various new features. It even provides an auto update mechanism allowing to replace the core JavaScript with a newer version.</p>
<p>If you want to save your Wiki content and settings you just have to allow the browser to re-save the local HTML file &#8211; using that it will just overwrite itself and remember its changes when you re-open the file in the future.</p>
<p>TiddlyWiki is intended to be used as a single user Wiki mostly, ranging from a powerful notebook or journal to a tool to document all your work. Since it creates backup copies of its previous state upon saving, you don&#8217;t have to fear losing all your work at once in the future.</p>
<p>I think it is really great fun to use and marks a new step in browser based software. After playing around for a while I quickly understood how to use it and what benefits one might gain from such a tool.</p>
<p>Try it out for yourself and have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vworld.at/2009/04/20/tiddlywiki-a-javascript-only-wiki-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>symfony at the &#8220;Linux weeks Vienna&#8221;</title>
		<link>http://blog.vworld.at/2009/04/15/symfony-at-the-linux-weeks-vienna/</link>
		<comments>http://blog.vworld.at/2009/04/15/symfony-at-the-linux-weeks-vienna/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 21:01:55 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://blog.vworld.at/?p=169</guid>
		<description><![CDATA[From April 16th to 18th the so-called Linux weeks will take place in the city hall of Vienna/Austria. There will be a symfony desk providing general information and exchange of personal experience using symfony. Bernhard Schussek and Klemens Ullmann, the heads behind webmozarts.com, will give 2 lectures about symfony in general and concrete projects. I [...]]]></description>
			<content:encoded><![CDATA[<p>From April 16th to 18th the so-called <em><a href="http://www.linuxwochen.at/index.php?option=com_content&#038;view=article&#038;id=4&#038;Itemid=32">Linux weeks</a></em> will take place in the city hall of Vienna/Austria. There will be a symfony desk providing general information and exchange of personal experience using symfony. Bernhard Schussek and Klemens Ullmann, the heads behind <a href="http://webmozarts.com/">webmozarts.com</a>, will give 2 lectures about symfony in general and concrete projects. I will be available at the symfony desk tomorrow (April 16th).</p>
<p>If you happen to be in Vienna at the time we&#8217;re looking forward to your visit!</p>
<p> Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vworld.at/2009/04/15/symfony-at-the-linux-weeks-vienna/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Improving the forms even more</title>
		<link>http://blog.vworld.at/2009/04/14/improving-the-forms-even-more/</link>
		<comments>http://blog.vworld.at/2009/04/14/improving-the-forms-even-more/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 07:38:02 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[OOp]]></category>

		<guid isPermaLink="false">http://blog.vworld.at/?p=149</guid>
		<description><![CDATA[After reading Bernhard&#8217;s great article about how the symfony forms framework could be enhanced I sat back and thought: how would I like the forms to be? What could be improved to increase my efficiency? Well, after 2 days of brain storming I have found those areas: Field grouping Field formatters Required marks Separators Submit [...]]]></description>
			<content:encoded><![CDATA[<p>After reading <a href="http://webmozarts.com/2009/04/12/improving-the-forms/">Bernhard&#8217;s great article about how the symfony forms framework could be enhanced</a> I sat back and thought: how would I like the forms to be? What could be improved to increase my efficiency? Well, after 2 days of brain storming I have found those areas:</p>
<ul>
<li>Field grouping</li>
<li>Field formatters</li>
<li>Required marks</li>
<li>Separators</li>
<li>Submit buttons</li>
<li>Help texts</li>
<li>I18n for everything</li>
</ul>
<p><span id="more-149"></span><br />
In my current symfony project at work I&#8217;m using at least 9 different forms, tendency rising. There are lots of things that would help making most of them easier to use.</p>
<h3>Field grouping</h3>
<p>The <a href="http://www.w3.org/TR/html401/interact/forms.html#h-17.10">W3C HTML specification provides a clean solution to grouping form fields: <em>fieldset</em> and <em>legend</em> elements</a>. Symfony doesn&#8217;t support them by now, but I think they are crucial, since lots of people use them and they are quite easy to define.<br />
Looking at Bernhard&#8217;s code sample let&#8217;s suppose we want to group the username and email fields and then the password fields:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> configure<span style="color: #009900;">&#40;</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;">addGroup</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user_stuff'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Personal information'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWidgetAttributes</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'max_length'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setValidatorOptions</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'max_length'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setValidator</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> sfValidatorEmail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addGroup</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password_stuff'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Password information'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">new</span> PasswordField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password_again'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWidget</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> sfWidgetPassword<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setValidator</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> sfValidatorPass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLabel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Password (again)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>In my imagination this should render like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">fieldset</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;user_stuff&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">legend</span>&gt;</span>Personal information<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">legend</span>&gt;</span>
  <span style="color: #808080; font-style: italic;">&lt;!-- The name and email form fields go here --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">fieldset</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;password_stuff&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">legend</span>&gt;</span>Password information<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">legend</span>&gt;</span>
  <span style="color: #808080; font-style: italic;">&lt;!-- The password form fields go here --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span></pre></div></div>

<p>The magic would be that &#8220;addGroup($name, $legendText)&#8221; would automatically close a previous group and add all further fields to the current group fieldset. To close a group manually and add the following fields to the global scope a closeGroup() method would be enough.<br />
The grouping HTML code would be defined in the form&#8217;s formatter, which can be enhanced easily:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> sfWidgetFormSchemaFormatterList <span style="color: #000000; font-weight: bold;">extends</span> sfWidgetFormSchemaFormatter
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">protected</span>
    <span style="color: #666666; font-style: italic;">// other stuff</span>
    <span style="color: #000088;">$groupFormat</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;fieldset&gt;<span style="color: #000099; font-weight: bold;">\n</span>  &lt;legend&gt;%legend%&lt;/legend&gt;<span style="color: #000099; font-weight: bold;">\n</span>  <span style="color: #009933; font-weight: bold;">%c</span>ontent%&lt;/fieldset&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And what if we add a form field later on that belongs to a previous group? Nothing easier than that!</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;">addFieldToGroup</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'surname'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'user_stuff'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>At the end of the article you&#8217;ll see why I think it would be useful to have this in the form definition.</p>
<h3>Field formatters</h3>
<p>Besides the grouping my forms share one more thing: not all the fields are rendered the same way. Some of them require parameters to the <em>label</em> tag or just completely different row stylings. The solution to this at the moment: I have to generate the row myself. The drawback: I&#8217;m usually too lazy to include stuff like error rendering and if I change the formatter one day I have to manually alter all the custom form field rows. There&#8217;s only one summary for this: it sucks!<br />
Why not enable custom formatters per row? There&#8217;s not even a need to define something new, we can re-use the existing formatter code!</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> configure<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;">//  This is how formatters are defined now:</span>
<span style="color: #666666; font-style: italic;">//  $this-&gt;widgetSchema-&gt;setFormFormatterName('List');</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//  Make it more intuitive in the first place:</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFormatterName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'List'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWidgetAttributes</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'max_length'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setValidatorOptions</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'max_length'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setValidator</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> sfValidatorEmail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">new</span> PasswordField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #666666; font-style: italic;">// here it comes!</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFormatterName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'customPasswordFormat'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password_again'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWidget</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> sfWidgetPassword<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setValidator</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> sfValidatorPass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLabel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Password (again)'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #666666; font-style: italic;">// and here!</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFormatterName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'customPasswordFormat'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>The only thing that changes here is that the 2 password fields would be formatted using another formatter. Everything else would stay the same. So simple and yet so powerful&#8230;</p>
<h3>Required marks</h3>
<p>There have been lots of discussions on the mailing lists how required fields should be displayed. My favourite solution would be to put this where all the other formatting stuff goes: to the formatter.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> sfWidgetFormSchemaFormatterList <span style="color: #000000; font-weight: bold;">extends</span> sfWidgetFormSchemaFormatter
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">protected</span>
    <span style="color: #000088;">$rowFormat</span>       <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;li&gt;<span style="color: #000099; font-weight: bold;">\n</span>  <span style="color: #009933; font-weight: bold;">%e</span>rror<span style="color: #009933; font-weight: bold;">%%</span>label<span style="color: #009933; font-weight: bold;">%%</span>required%<span style="color: #000099; font-weight: bold;">\n</span>  <span style="color: #009933; font-weight: bold;">%f</span>ield<span style="color: #009933; font-weight: bold;">%%</span>help%<span style="color: #000099; font-weight: bold;">\n</span>%hidden_fields%&lt;/li&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
    <span style="color: #666666; font-style: italic;">// other stuff</span>
    <span style="color: #000088;">$requiredFormat</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;span&gt;*&lt;/span&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Combined with the ability to define custom styles per field this would be a powerful solution.<br />
Ah, there&#8217;s something else I would like to notice: defining the <em>required</em> property in the validator is fine from a techie-architect-point-of-view (as are so many other form related issues). But let&#8217;s once more see it from the user&#8217;s perspective:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> configure<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;">// old way</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWidgetAttributes</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'max_length'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setValidatorOptions</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'max_length'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'required'</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: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// what about this?</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWidgetAttributes</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'max_length'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setValidatorOptions</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'max_length'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setRequired</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>See the difference? I&#8217;d personally like to have both options, but the second one would be much more intuitive from the user&#8217;s point of view.</p>
<h3>Separators</h3>
<p><em><strong>Update 2009-04-16: I&#8217;m not sure anymore that separators like I described them here are a good idea. I&#8217;ll keep the content unchanged for anyone to understand the discussion that followed. Keep in mind that all this is a kind of brain storming which naturally results in more storm than brain <img src='http://blog.vworld.at/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</strong></em></p>
<p>Separators are quite useful in templates when 2 form rows shouldn&#8217;t be too close to each other or separated visually using a horizontal line or whatever. In the template this is usually done like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderRow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  &lt;div class=&quot;separator&quot;&gt;&lt;/div&gt;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderRow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Let&#8217;s extend the formatter first (you know what I&#8217;m getting at, don&#8217;t you?):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> sfWidgetFormSchemaFormatterList <span style="color: #000000; font-weight: bold;">extends</span> sfWidgetFormSchemaFormatter
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">protected</span>
    <span style="color: #666666; font-style: italic;">// other stuff</span>
    <span style="color: #000088;">$separatorFormat</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;div class=&quot;separator&quot;&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now we can use it in the form code. And we can use different separators in the same form!</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> configure<span style="color: #009900;">&#40;</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;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWidgetAttributes</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'max_length'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setValidatorOptions</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'max_length'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addSeparator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setValidator</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> sfValidatorEmail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addSeparator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFormatterName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'anotherSeparatorFormat'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">new</span> PasswordField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Submit buttons</h3>
<p>Submit buttons belong to the form. They are even input widgets from a technical point of view. So why not add them to the form definition?</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> configure<span style="color: #009900;">&#40;</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;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWidgetAttributes</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'max_length'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setValidatorOptions</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'max_length'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// all the other fields </span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// solution 1</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'submit'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWidget</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> sfWidgetSubmit<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Submit the form'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setValidator</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> sfValidatorPass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// solution 2</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addSubmitButton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'submit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Submit the form'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Together with the ability to use a specific formatter for the submit widget this would make every kind of submit button possible.</p>
<h3>Help texts</h3>
<p>So far the only possible way to add help texts to your form is passing them to the renderRow() method like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderRow</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Label text'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Help text'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Why is this separated from the form definition? Especially if the label is defined inside the form? Are there scenarios where the label stays the same but the help text changes? I don&#8217;t think so!<br />
Let&#8217;s try an alternative approach:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> configure<span style="color: #009900;">&#40;</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;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWidgetAttributes</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'max_length'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setValidatorOptions</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'max_length'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLabel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Label text'</span><span style="color: #009900;">&#41;</span>
         <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setHelp</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Help text'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You see that this is mixing content with structure. But since most of the forms stuff is mixing content with structure (otherwise the labels should never have been in the form definition in the first place) why not allow to do it properly? And this leads to my last point:</p>
<h3>I18n for everything</h3>
<p>Symfony is great. Symfony has many powerful features. Symfony supports internationalization (short i18n) for everything. Everything? Not so! The form classes strictly defy being i18ned (sic!), making you wrap labels and help texts in <em>__()</em> functions in the template and hoping that the users don&#8217;t mind english error messages. Is there a reason for this? Of course: removing the form&#8217;s dependency to use an i18n instance. Is this necessary? I don&#8217;t think so:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> configure<span style="color: #009900;">&#40;</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;">enableI18n</span><span style="color: #009900;">&#40;</span>sfContext<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getI18n</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Inject the i18n instance into the form. After that, everything could be translated: labels, help texts, messages, errors, even formatters! If you don&#8217;t want to use it, don&#8217;t. If you need it, make sure you get the damn i18n instance into the form somehow (there are solutions&#8230;). I know this is not easy because it changes how most of the widgets are rendered. But I think it would be worth the price.</p>
<h3>Why do I want all this stuff?</h3>
<p>That&#8217;s lots of feature requests. That&#8217;s lots of extensions and changes to the forms framework. But why? I can tell you! Because if all of the above features were available, <strong>80% of my form templates could look like this</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">render</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Wouldn&#8217;t that be worth it? Wouldn&#8217;t that help the core powers of symfony: KISS and DRY? I know that some projects have different people for generating form code and markup, but I think most work is done by the same developers. At least this would provide an option to do it differently.</p>
<p>Comments are welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vworld.at/2009/04/14/improving-the-forms-even-more/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

