<?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>Musings of ErisDS &#187; Symfony</title> <atom:link href="http://erisds.co.uk/category/symfony/feed" rel="self" type="application/rss+xml" /><link>http://erisds.co.uk</link> <description>Web development, Symfony, Wordpress and general geekery</description> <lastBuildDate>Tue, 19 Jan 2010 18:54:13 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.1</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Symfony: New Static Text Management Plugin</title><link>http://erisds.co.uk/symfony/symfony-new-static-text-management-plugin</link> <comments>http://erisds.co.uk/symfony/symfony-new-static-text-management-plugin#comments</comments> <pubDate>Wed, 15 Jul 2009 12:59:22 +0000</pubDate> <dc:creator>ErisDS</dc:creator> <category><![CDATA[Symfony]]></category> <category><![CDATA[cms]]></category> <category><![CDATA[plugins]]></category> <category><![CDATA[web development]]></category><guid
isPermaLink="false">http://erisds.co.uk/?p=626</guid> <description><![CDATA[Generally, when I find something interesting I use twitter &#038; delicious to spread the word, but this morning something in my RSS Reader got me excited enough to decide to write a blog post. Thomas Rabaix has hit the nail on the head with his latest offering: <a
href="http://rabaix.net/en/articles/2009/07/14/wording-is-not-a-developer-job-">Wording is not a developer job</a>. Not only with his underlying premise, but also with the solution he has developed and offered to the world.Related posts:<ol><li><a
href='http://erisds.co.uk/wordpress/spotlight-wordpress-pods-plugin' rel='bookmark' title='Permanent Link: Spotlight: Wordpress Pods Plugin'>Spotlight: Wordpress Pods Plugin</a> <small>Have you ever needed to build a website which fit...</small></li><li><a
href='http://erisds.co.uk/symfony/symfony-what-is-it-good-for' rel='bookmark' title='Permanent Link: Symfony: What is it good for?'>Symfony: What is it good for?</a> <small>Symfony is one of my favourite bits of technology. I’ve...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-user-access-the-user-object' rel='bookmark' title='Permanent Link: Snippet: Symfony User &#8211; Access the User Object'>Snippet: Symfony User &#8211; Access the User Object</a> <small>The following snippets provide access to the Symfony User object...</small></li></ol>]]></description> <content:encoded><![CDATA[<p>Generally, when I find something interesting I use twitter &#038; delicious to spread the word, but this morning something in my RSS Reader got me excited enough to decide to write a blog post. Thomas Rabaix has hit the nail on the head with his latest offering: <a
href="http://rabaix.net/en/articles/2009/07/14/wording-is-not-a-developer-job-">Wording is not a developer job</a>. Not only with his underlying premise, but also with the solution he has developed to solve the problem of managing static content.</p><p>All-too-often developers are sent change requests which are nothing more than to fix a typo, update an address or fix an incorrect translation. The time taken to locate, modify, and re-deploy these changes are often disproportionate with the amount of work a client would consider was involved. What Thomas&#8217; plugin does, is add to Symfony&#8217;s I18n (Internationalisation) capabilities so that all static text, in multiple languages, can be managed via a CMS-like control panel.</p><p>With this plugin, the power to manage all text in a web app can be handed over to clients with the rest of the administration panel. This has the benefit of further seperating content &#038; function, and the roles of copywriter, content manager, and web developer. Now if only there was a similar tool for Wordpress, my typo-fixing days would be over!</p><p>Related posts:<ol><li><a
href='http://erisds.co.uk/wordpress/spotlight-wordpress-pods-plugin' rel='bookmark' title='Permanent Link: Spotlight: Wordpress Pods Plugin'>Spotlight: Wordpress Pods Plugin</a> <small>Have you ever needed to build a website which fit...</small></li><li><a
href='http://erisds.co.uk/symfony/symfony-what-is-it-good-for' rel='bookmark' title='Permanent Link: Symfony: What is it good for?'>Symfony: What is it good for?</a> <small>Symfony is one of my favourite bits of technology. I’ve...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-user-access-the-user-object' rel='bookmark' title='Permanent Link: Snippet: Symfony User &#8211; Access the User Object'>Snippet: Symfony User &#8211; Access the User Object</a> <small>The following snippets provide access to the Symfony User object...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://erisds.co.uk/symfony/symfony-new-static-text-management-plugin/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Snippet: Symfony Forms &#8211; Definition List Form Formatter</title><link>http://erisds.co.uk/symfony/snippet-symfony-forms-definition-list-form-formatter</link> <comments>http://erisds.co.uk/symfony/snippet-symfony-forms-definition-list-form-formatter#comments</comments> <pubDate>Tue, 02 Jun 2009 12:59:42 +0000</pubDate> <dc:creator>ErisDS</dc:creator> <category><![CDATA[Symfony]]></category> <category><![CDATA[forms]]></category> <category><![CDATA[snippet]]></category><guid
isPermaLink="false">http://erisds.co.uk/?p=396</guid> <description><![CDATA[<p>Back in April I posted a Snippet on <a
href="http://erisds.co.uk/symfony/snippet-symfony-forms-setting-the-form-formatter">Symfony Form Formatters</a>. Since then I've done a bit more work with them and thought I'd share my custom form formatter for displaying forms as definition lists. Forms are often marked up as unordered lists, but with their label-input structure I find they often make semantic sense as definition lists.</p>Related posts:<ol><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-the-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting the Form Formatter'>Snippet: Symfony Forms &#8211; Setting the Form Formatter</a> <small>By default Symfony displays forms in tables, with each new...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting Default Values'>Snippet: Symfony Forms &#8211; Setting Default Values</a> <small>I often forget how to set default values for form...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-allowing-extra-fields' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Allowing Extra Fields'>Snippet: Symfony Forms &#8211; Allowing Extra Fields</a> <small>Place this line of code in the configure method of...</small></li></ol>]]></description> <content:encoded><![CDATA[<p>Back in April I posted a Snippet on <a
href="http://erisds.co.uk/symfony/snippet-symfony-forms-setting-the-form-formatter">Symfony Form Formatters</a>. Since then I&#8217;ve done a bit more work with them and thought I&#8217;d share my custom form formatter for displaying forms as definition lists. Forms are often marked up as unordered lists, but with their label-input structure I find they often make semantic sense as definition lists.</p><p>To create the formatter paste this code into a new file and name it sfWidgetFormSchemaFormatterDefList.class.php. I saved it in /lib but it also makes sense to put it in /lib/form, depending on your personal preference.</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
/>13<br
/></div></td><td><div
class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span
style="color: #000000; font-weight: bold;">&lt;?php</span><br
/> &nbsp;<span
style="color: #666666; font-style: italic;">// lib/sfWidgetFormSchemaFormatterDefList.class.php</span><br
/> <span
style="color: #000000; font-weight: bold;">class</span> sfWidgetFormSchemaFormatterDefList <span
style="color: #000000; font-weight: bold;">extends</span> sfWidgetFormSchemaFormatter <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; protected<br
/> &nbsp; &nbsp; &nbsp; <span
style="color: #000088;">$rowFormat</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">'&lt;dt&gt;%label%&lt;dd&gt;%error%%field%%help%%hidden_fields%&lt;/dd&gt;'</span><span
style="color: #339933;">,</span><br
/> &nbsp; &nbsp; &nbsp; <span
style="color: #000088;">$helpFormat</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span
style="color: #339933;">=</span> <span
style="color: #0000ff;">'&lt;span class=&quot;help&quot;&gt;%help%&lt;/span&gt;'</span><span
style="color: #339933;">,</span><br
/> &nbsp; &nbsp; &nbsp; <span
style="color: #000088;">$errorRowFormat</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span
style="color: #339933;">=</span> <span
style="color: #0000ff;">'&lt;dt class=&quot;error&quot;&gt;Errors:&lt;/dt&gt;&lt;dd&gt;%errors%&lt;/dd&gt;'</span><span
style="color: #339933;">,</span><br
/> &nbsp; &nbsp; &nbsp; <span
style="color: #000088;">$errorListFormatInARow</span> &nbsp; &nbsp; <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">'&lt;ul class=&quot;error_list&quot;&gt;%errors%&lt;/ul&gt;'</span><span
style="color: #339933;">,</span><br
/> &nbsp; &nbsp; &nbsp; <span
style="color: #000088;">$errorRowFormatInARow</span> &nbsp; &nbsp; &nbsp;<span
style="color: #339933;">=</span> <span
style="color: #0000ff;">'&lt;li&gt;%error%&lt;/li&gt;'</span><span
style="color: #339933;">,</span><br
/> &nbsp; &nbsp; &nbsp; <span
style="color: #000088;">$namedErrorRowFormatInARow</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">'&lt;li&gt;%name%: %error%&lt;/li&gt;'</span><span
style="color: #339933;">,</span><br
/> &nbsp; &nbsp; &nbsp; <span
style="color: #000088;">$decoratorFormat</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">'&lt;dl id=&quot;formContainer&quot;&gt;%content%&lt;/dl&gt;'</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #009900;">&#125;</span><br
/> <span
style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div><p>To use this formatter in a form you&#8217;ll need to add the following three lines of code to first add the formatter and assign it to a name, and then set the formatter for the current form.</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
/></div></td><td><div
class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span
style="color: #000000; font-weight: bold;">&lt;?php</span><br
/> &nbsp;<span
style="color: #666666; font-style: italic;">// lib/form/MyModelForm.class.php</span><br
/> &nbsp;<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><br
/> &nbsp; <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; <span
style="color: #000088;">$custom_decorator</span> <span
style="color: #339933;">=</span> <span
style="color: #000000; font-weight: bold;">new</span> sfWidgetFormSchemaFormatterDefList<span
style="color: #009900;">&#40;</span><span
style="color: #000088;">$this</span><span
style="color: #339933;">-&gt;</span><span
style="color: #004000;">getWidgetSchema</span><span
style="color: #009900;">&#40;</span><span
style="color: #009900;">&#41;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #000088;">$this</span><span
style="color: #339933;">-&gt;</span><span
style="color: #004000;">getWidgetSchema</span><span
style="color: #009900;">&#40;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">-&gt;</span><span
style="color: #004000;">addFormFormatter</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">'deflist'</span><span
style="color: #339933;">,</span> <span
style="color: #000088;">$custom_decorator</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #000088;">$this</span><span
style="color: #339933;">-&gt;</span><span
style="color: #004000;">getWidgetSchema</span><span
style="color: #009900;">&#40;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">-&gt;</span><span
style="color: #004000;">setFormFormatterName</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">'deflist'</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>Please let me know if you have any problems with this snippet, or if you find it useful!</p><p
class="small"><strong>A Note on Snippets:</strong> When using frameworks such as Symfony it is often the simplest pieces of code which are the hardest to either find or remember. These snippets are placed here for my own reference and will hopefully be useful to others. If you find them useful or have any suggestions, please let me know.</p><p>Related posts:<ol><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-the-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting the Form Formatter'>Snippet: Symfony Forms &#8211; Setting the Form Formatter</a> <small>By default Symfony displays forms in tables, with each new...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting Default Values'>Snippet: Symfony Forms &#8211; Setting Default Values</a> <small>I often forget how to set default values for form...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-allowing-extra-fields' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Allowing Extra Fields'>Snippet: Symfony Forms &#8211; Allowing Extra Fields</a> <small>Place this line of code in the configure method of...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://erisds.co.uk/symfony/snippet-symfony-forms-definition-list-form-formatter/feed</wfw:commentRss> <slash:comments>11</slash:comments> </item> <item><title>Symfony: What is it good for?</title><link>http://erisds.co.uk/symfony/symfony-what-is-it-good-for</link> <comments>http://erisds.co.uk/symfony/symfony-what-is-it-good-for#comments</comments> <pubDate>Sun, 26 Apr 2009 14:20:00 +0000</pubDate> <dc:creator>ErisDS</dc:creator> <category><![CDATA[Symfony]]></category> <category><![CDATA[forms]]></category> <category><![CDATA[frameworks]]></category> <category><![CDATA[web development]]></category><guid
isPermaLink="false">http://erisds.co.uk/?p=119</guid> <description><![CDATA[Symfony is one of my favourite bits of technology. I’ve got plans to write several articles and tutorials on it, but as I know many people haven’t yet heard of it, or are unaware of how it could help them, I thought it best to write an introductory article. So, here is an explanation of what Symfony is, why I use it, and why <em>you</em> may want to start using it too.Related posts:<ol><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-user-access-the-user-object' rel='bookmark' title='Permanent Link: Snippet: Symfony User &#8211; Access the User Object'>Snippet: Symfony User &#8211; Access the User Object</a> <small>The following snippets provide access to the Symfony User object...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-allowing-extra-fields' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Allowing Extra Fields'>Snippet: Symfony Forms &#8211; Allowing Extra Fields</a> <small>Place this line of code in the configure method of...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-the-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting the Form Formatter'>Snippet: Symfony Forms &#8211; Setting the Form Formatter</a> <small>By default Symfony displays forms in tables, with each new...</small></li></ol>]]></description> <content:encoded><![CDATA[<p><a
href="http://symfony-project.org"><img
class="align-right" title="Symfony Project Homepage" src="http://erisds.co.uk/wp-content/uploads/2009/04/symfony.jpg" alt="Symfony Project Homepage" width="320" height="350" /></a><a
href="http://symfony-project.org">Symfony</a> is one of my favourite bits of technology. I&#8217;ve got plans to write several articles and tutorials on it, but as I know many people haven&#8217;t yet heard of it, or are unaware of how it could help them, I thought it best to write an introductory article. So, here is an explanation of what Symfony is, why I use it, and why <em>you</em> may want to start using it too.</p><p>Symfony is a <a
href="http://en.wikipedia.org/wiki/Php_framework#PHP">PHP framework</a>. It is a large volume of extremely useful bits of code written in PHP and collected together under a common name, with lots of documentation and a set of additional tools to make web development easier, faster and safer! It aims to make the life of a developer much, much simpler.</p><h3>What does Symfony do?</h3><ul><li>Drastically reduce the <strong>amount of code</strong> written</li><li>Vastly reduce <strong>development time</strong></li><li>Improve the <strong>standard of coding</strong> in web apps</li><li>Not reinvent the wheel</li></ul><p>Symfony contains a vast quantity of code needed to get any database-driven web application up and running, along with several tools to automate common tasks. A developer only has to specify the data model/structures which are needed for her application in a special format called <a
title="YAML Ain't Markup Language" href="http://www.yaml.org/">YAML</a>, then Symfony will build the database tables and create all the classes needed to access and retrieve the data as objects along with basic templates and forms for viewing and entering the data. Symfony also has an admin generator, meaning it is capable of building a complete administration system for the data. The amount of code written by the developer is minimised, and the development time is significantly reduced.</p><p>Symfony follows the <a
href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">Model-View-Controller (MVC) pattern</a> and is completely <a
href="http://en.wikipedia.org/wiki/Object_Oriented">Object Oriented</a>. This means the code is organised, flexible, and extensible &#8211; if Symfony doesn&#8217;t work the way you want it to, you always have the option to override the functionality. Developers are encouraged to follow the patterns and best practices used in Symfony in their own code, thus improving the overall standard of coding.</p><p>What Symfony doesn&#8217;t do, is reinvent the wheel &#8211; it makes use of already proven tools where possible. For example Symfony supports either <a
href="http://propel.phpdb.org/trac/">Propel</a> or <a
href="http://www.doctrine-project.org/">Doctrine</a> as the <a
title="Object-Relational Mapping" href="http://en.wikipedia.org/wiki/Object-relational_mapping">ORM</a> layer (for interacting with the database &#8211; I use Propel) and uses <a
title="PHing Is Not Gnu make" href="http://phing.info/trac/">Phing</a> for building projects. Functionality like search or sending mail is not included in the Symfony framework, instead there are plugins in the extensive plugin library and tutorials on how to include popular libraries from the Zend framework. This keeps Symfony lightweight and focused on what it does best, meanwhile developers have the flexibility to use their favourite tools rather than &#8220;what&#8217;s in the box&#8221;.</p><h3>So what does the developer do?</h3><p>Symfony does a great deal of the groundwork of setting up a web application, but it can only do so much. Because the code to create, edit, list and show the data is generated by Symfony from the data model, the resulting display and functionality is very generic. The developer then has the job of building templates, configuring forms, modifying data, and implementing advanced functionality.</p><p>The <a
href="http://www.symfony-project.org/tutorial/1_2/my-first-project">My First Symfony Project</a> tutorial takes you through the basics of setting up a blog. After defining the data model for blog posts &amp; comments and generating the <abbr
title="Create, Read, Update and Delete">CRUD</abbr> code, the list view, which would effectively be the blog&#8217;s index page, looks like this:<br
/> <a
href="http://www.symfony-project.org/tutorial/1_2/my-first-project"><img
class="align-left" title="My First Symfony Project" src="http://erisds.co.uk/wp-content/uploads/2009/04/myfirstsymfonyproject.gif" alt="My First Symfony Project" width="600" height="167" /></a></p><p>Clearly, this looks nothing like a traditional blog. The ID and body don&#8217;t need to be displayed, the title should link to the &#8220;single&#8221; view, there is no indication of how many comments each post has and the created at date needs to be formatted to be more human-friendly. There are also many features missing such as searching, RSS feeds, categories, tags and user profiles. The additional features, data formatting and the HTML + CSS templates all need to be implemented by the developer, so there is still plenty of work to do.</p><h3>What is Symfony good at?</h3><p>Symfony is excellent for building any website which features content management or web services. The ability to specify data models (or content types if you want to think of it that way) and get the basic <abbr
title="Create, Read, Update and Delete">CRUD</abbr> functionality up and running quickly, means that small content management systems can be a breeze to build. In addition to this, Symfony follows a <a
title="Representational State Transfer" href="http://en.wikipedia.org/wiki/Representational_State_Transfer">RESTful architecture</a> and has a very extensive and flexible routing system for building URLs. This means creating pretty URLs is simple, and providing web services via specific URLs is also easy to do (think twitter feeds being provided at http://twitter.com/username).</p><p>The more I learn about Symfony, the more I love it. I&#8217;m using it to build all those little personal projects that I would otherwise never have time to complete due to the overhead of time required to get the simplest function (data handling, pretty URLs, user management) working from scratch. I also find that working with Symfony gives me a greater sense of satisfaction because I feel that the code I am producing is of a higher standard and much more reliable. I thoroughly recommend trying it out, even if you just run through the tutorials and pick up some good programming practices.</p><h3>So what next?</h3><p>Symfony does have quite a steep learning curve, and if you&#8217;re planning to get started, there are a few things that you will need to be comfortable with first:</p><ul><li>The <a
href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">Model-View-Controller (MVC) pattern</a></li><li><a
href="http://en.wikipedia.org/wiki/Object_Oriented">Object Oriented Programming principles</a> (objects, data abstraction, inheritance etc)</li><li>Basic PHP, SQL and database management knowledge</li><li>Development environment setup &amp; management (virtual hosts, symlinks etc)</li></ul><p>You don&#8217;t need to be an expert or even proficient in these things, but arming yourself with knowledge of these tools will not only ease your journey with Symfony, but will also improve your overall experience with programming, scripting and development tasks. I really recommend a little background reading!</p><p>Once you are ready to put your best foot forward and give Symfony a go, then the only way to get started is with a tutorial. Dive in with the <a
href="http://www.symfony-project.org/tutorial/1_2/my-first-project">My First Symfony Project</a> tutorial, and then move on to the <a
href="http://www.symfony-project.org/jobeet/1_2/Propel/en/">Jobeet</a> job board tutorial, which is much more in depth and shows you how to put into practice some of the more advanced features. There is plenty of other material to help you get started, including the <a
href="http://www.symfony-project.org/doc/1_2/">documentation &amp; API</a>, the <a
href="http://forum.symfony-project.org/">forums</a>, the <a
href="http://www.symfony-project.org/blog/">blog</a>, the <a
href="http://feeds.feedburner.com/symfony/planet">outside blogs RSS feed</a>, the <a
href="http://groups.google.com/group/symfony-users">google users group</a> and of course, <a
href="http://erisds.co.uk/tag/snippet">my snippet library</a>!</p><p>I hope that this article has explained what Symfony is all about and also whet your appetite for learning it. If there is anything else you want to know, or feel could be added to improve this introduction, please drop me a line in the comments. Otherwise I wish you good luck on your journey with Symfony, let me know how you get on!</p><p>Related posts:<ol><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-user-access-the-user-object' rel='bookmark' title='Permanent Link: Snippet: Symfony User &#8211; Access the User Object'>Snippet: Symfony User &#8211; Access the User Object</a> <small>The following snippets provide access to the Symfony User object...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-allowing-extra-fields' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Allowing Extra Fields'>Snippet: Symfony Forms &#8211; Allowing Extra Fields</a> <small>Place this line of code in the configure method of...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-the-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting the Form Formatter'>Snippet: Symfony Forms &#8211; Setting the Form Formatter</a> <small>By default Symfony displays forms in tables, with each new...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://erisds.co.uk/symfony/symfony-what-is-it-good-for/feed</wfw:commentRss> <slash:comments>13</slash:comments> </item> <item><title>Snippet: Symfony Forms &#8211; Setting the Form Formatter</title><link>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-the-form-formatter</link> <comments>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-the-form-formatter#comments</comments> <pubDate>Tue, 21 Apr 2009 20:35:38 +0000</pubDate> <dc:creator>ErisDS</dc:creator> <category><![CDATA[Symfony]]></category> <category><![CDATA[forms]]></category> <category><![CDATA[snippet]]></category><guid
isPermaLink="false">http://erisds.co.uk/?p=222</guid> <description><![CDATA[<p>By default Symfony displays forms in tables, with each new input being a table row. If you want to display your forms more semantically with fieldsets and lists, Symfony has a list formatter built in. You can tell an individual form to display as a list using the code below.</p><code
lang="php" tab_size="2"> < ?php
// lib/form/MyModelForm.class.php
public function configure() {
$this->widgetSchema->setFormFormatterName('list');
}
?></code>Related posts:<ol><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-definition-list-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Definition List Form Formatter'>Snippet: Symfony Forms &#8211; Definition List Form Formatter</a> <small>Back in April I posted a Snippet on Symfony Form...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting Default Values'>Snippet: Symfony Forms &#8211; Setting Default Values</a> <small>I often forget how to set default values for form...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-allowing-extra-fields' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Allowing Extra Fields'>Snippet: Symfony Forms &#8211; Allowing Extra Fields</a> <small>Place this line of code in the configure method of...</small></li></ol>]]></description> <content:encoded><![CDATA[<p>By default Symfony displays forms in tables, with each new input being a table row. If you want to display your forms more semantically with fieldsets and lists, Symfony has a list formatter built in. You can tell an individual form to display as a list using the code below.</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
/></div></td><td><div
class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span
style="color: #000000; font-weight: bold;">&lt;?php</span><br
/> &nbsp; &nbsp; <span
style="color: #666666; font-style: italic;">// lib/form/MyModelForm.class.php</span><br
/> &nbsp; &nbsp; <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><br
/> &nbsp; &nbsp; &nbsp; <span
style="color: #000088;">$this</span><span
style="color: #339933;">-&gt;</span><span
style="color: #004000;">widgetSchema</span><span
style="color: #339933;">-&gt;</span><span
style="color: #004000;">setFormFormatterName</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">'list'</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span> <br
/> <span
style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div><p>You can also create your own custom formatters. For detailed examples of how to do this see the following tutorials:</p><ul><li><a
href="http://erisds.co.uk/symfony/snippet-symfony-forms-definition-list-form-formatter">My Custom Definition List Form Formatter for Symfony</a></li><li><a
href="http://snippets.symfony-project.org/snippet/304">Create a Div formatter (Scroll down to &#8220;Formatter&#8221;)</a></li><li><a
href="http://dark-it.blogspot.com/2009/01/symfony-mark-fields-as-required.html">Automatically mark required fields</a></li><li><a
href="http://www.thatsquality.com/articles/7-days-of-symfony-1-1-forms-widgets-and-validators-day7">Create a custom formatter inline or with your own class</a></li></ul><p
class="small"><strong>A Note on Snippets:</strong> When using frameworks such as Symfony it is often the simplest pieces of code which are the hardest to either find or remember. These snippets are placed here for my own reference and will hopefully be useful to others. If you find them useful or have any suggestions, please let me know.</p><p>Related posts:<ol><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-definition-list-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Definition List Form Formatter'>Snippet: Symfony Forms &#8211; Definition List Form Formatter</a> <small>Back in April I posted a Snippet on Symfony Form...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting Default Values'>Snippet: Symfony Forms &#8211; Setting Default Values</a> <small>I often forget how to set default values for form...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-allowing-extra-fields' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Allowing Extra Fields'>Snippet: Symfony Forms &#8211; Allowing Extra Fields</a> <small>Place this line of code in the configure method of...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-the-form-formatter/feed</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Snippet: Symfony Forms &#8211; Setting Default Values</title><link>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values</link> <comments>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values#comments</comments> <pubDate>Sat, 11 Apr 2009 08:37:57 +0000</pubDate> <dc:creator>ErisDS</dc:creator> <category><![CDATA[Symfony]]></category> <category><![CDATA[forms]]></category> <category><![CDATA[snippet]]></category><guid
isPermaLink="false">http://erisds.co.uk/?p=97</guid> <description><![CDATA[<p>I often forget how to set default values for form fields. Mainly because it's a function of sfForm rather than sfFormField I think. I the snippet below 'field' you are setting the default value for, and $value should be the default value.</p><code
lang="php" tab_size="2"> $this->setDefault('field', $value); </code>Related posts:<ol><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-the-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting the Form Formatter'>Snippet: Symfony Forms &#8211; Setting the Form Formatter</a> <small>By default Symfony displays forms in tables, with each new...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-allowing-extra-fields' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Allowing Extra Fields'>Snippet: Symfony Forms &#8211; Allowing Extra Fields</a> <small>Place this line of code in the configure method of...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-definition-list-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Definition List Form Formatter'>Snippet: Symfony Forms &#8211; Definition List Form Formatter</a> <small>Back in April I posted a Snippet on Symfony Form...</small></li></ol>]]></description> <content:encoded><![CDATA[<p>I often forget how to set default values for form fields. Mainly because it&#8217;s a function of sfForm rather than sfFormField I think. In the snippet below &#8216;field&#8217; you are setting the default value for, and $value should be the default value.</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
/></div></td><td><div
class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span
style="color: #000000; font-weight: bold;">&lt;?php</span><br
/> &nbsp; &nbsp; <span
style="color: #666666; font-style: italic;">// lib/form/MyModelForm.class.php</span><br
/> &nbsp; &nbsp; <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><br
/> &nbsp; &nbsp; &nbsp; <span
style="color: #000088;">$this</span><span
style="color: #339933;">-&gt;</span><span
style="color: #004000;">setDefault</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">'field'</span><span
style="color: #339933;">,</span> <span
style="color: #000088;">$value</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span> <br
/> <span
style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div><p
class="small"><strong>A Note on Snippets:</strong> When using frameworks such as Symfony it is often the simplest pieces of code which are the hardest to either find or remember. These snippets are placed here for my own reference and will hopefully be useful to others. If you find them useful or have any suggestions, please let me know.</p><p>Related posts:<ol><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-the-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting the Form Formatter'>Snippet: Symfony Forms &#8211; Setting the Form Formatter</a> <small>By default Symfony displays forms in tables, with each new...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-allowing-extra-fields' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Allowing Extra Fields'>Snippet: Symfony Forms &#8211; Allowing Extra Fields</a> <small>Place this line of code in the configure method of...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-definition-list-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Definition List Form Formatter'>Snippet: Symfony Forms &#8211; Definition List Form Formatter</a> <small>Back in April I posted a Snippet on Symfony Form...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values/feed</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>Snippet: Symfony User &#8211; Access the User Object</title><link>http://erisds.co.uk/symfony/snippet-symfony-user-access-the-user-object</link> <comments>http://erisds.co.uk/symfony/snippet-symfony-user-access-the-user-object#comments</comments> <pubDate>Fri, 10 Apr 2009 22:09:00 +0000</pubDate> <dc:creator>ErisDS</dc:creator> <category><![CDATA[Symfony]]></category> <category><![CDATA[forms]]></category> <category><![CDATA[snippet]]></category> <category><![CDATA[user]]></category><guid
isPermaLink="false">http://erisds.co.uk/?p=83</guid> <description><![CDATA[<p>The following snippets provide access to the Symfony User object from various parts of a Symfony project.</p>Related posts:<ol><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-the-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting the Form Formatter'>Snippet: Symfony Forms &#8211; Setting the Form Formatter</a> <small>By default Symfony displays forms in tables, with each new...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting Default Values'>Snippet: Symfony Forms &#8211; Setting Default Values</a> <small>I often forget how to set default values for form...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-allowing-extra-fields' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Allowing Extra Fields'>Snippet: Symfony Forms &#8211; Allowing Extra Fields</a> <small>Place this line of code in the configure method of...</small></li></ol>]]></description> <content:encoded><![CDATA[<p>The following snippets provide access to the Symfony User object from various parts of a Symfony project.</p><h3>Template / View</h3><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
/></div></td><td><div
class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span
style="color: #000088;">$user</span> <span
style="color: #339933;">=</span> <span
style="color: #000088;">$sf_user</span><span
style="color: #339933;">;</span></div></td></tr></tbody></table></div><h3>Model or Form</h3><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
/></div></td><td><div
class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span
style="color: #000088;">$user</span> <span
style="color: #339933;">=</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;">getUser</span><span
style="color: #009900;">&#40;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></td></tr></tbody></table></div><p>Note: the context isn&#8217;t setup when using the command line, therefore if you use this in the save() method of an object and try to populate the object from a data-load it will throw an error: &#8216;The &#8220;default&#8221; context does not exist&#8217;.</p><h3>Action</h3><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
/></div></td><td><div
class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span
style="color: #000088;">$user</span> <span
style="color: #339933;">=</span> <span
style="color: #000088;">$this</span><span
style="color: #339933;">-&gt;</span><span
style="color: #004000;">getUser</span><span
style="color: #009900;">&#40;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></td></tr></tbody></table></div><p>or</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
/></div></td><td><div
class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span
style="color: #000088;">$user</span> <span
style="color: #339933;">=</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;">getUser</span><span
style="color: #009900;">&#40;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></td></tr></tbody></table></div><h2>sfGuardUser and sfGuardUserProfile</h2><p>sfGuard is a popular plugin for Symfony which provides a complete set of tools for managing users, groups, permissions and profiles. Once the user object has been retrieved as above, the sfGuard user and profile are accessed as follows:</p><h3>Template / View</h3><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
/></div></td><td><div
class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span
style="color: #000088;">$profile</span> <span
style="color: #339933;">=</span> <span
style="color: #000088;">$user</span><span
style="color: #339933;">-&gt;</span><span
style="color: #004000;">getGuardUser</span><span
style="color: #009900;">&#40;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">-&gt;</span><span
style="color: #004000;">getProfile</span><span
style="color: #009900;">&#40;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></td></tr></tbody></table></div><p
class="small"><strong>A Note on Snippets:</strong> When using frameworks such as Symfony it is often the simplest pieces of code which are the hardest to either find or remember. These snippets are placed here for my own reference and will hopefully be useful to others. If you find them useful or have any suggestions, please let me know.</p><p>Related posts:<ol><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-the-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting the Form Formatter'>Snippet: Symfony Forms &#8211; Setting the Form Formatter</a> <small>By default Symfony displays forms in tables, with each new...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting Default Values'>Snippet: Symfony Forms &#8211; Setting Default Values</a> <small>I often forget how to set default values for form...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-allowing-extra-fields' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Allowing Extra Fields'>Snippet: Symfony Forms &#8211; Allowing Extra Fields</a> <small>Place this line of code in the configure method of...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://erisds.co.uk/symfony/snippet-symfony-user-access-the-user-object/feed</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>Snippet: Symfony Forms &#8211; Allowing Extra Fields</title><link>http://erisds.co.uk/symfony/snippet-symfony-forms-allowing-extra-fields</link> <comments>http://erisds.co.uk/symfony/snippet-symfony-forms-allowing-extra-fields#comments</comments> <pubDate>Mon, 06 Apr 2009 22:03:25 +0000</pubDate> <dc:creator>ErisDS</dc:creator> <category><![CDATA[Symfony]]></category> <category><![CDATA[forms]]></category> <category><![CDATA[propel]]></category> <category><![CDATA[snippet]]></category><guid
isPermaLink="false">http://erisds.co.uk/?p=40</guid> <description><![CDATA[<p>Place this line of code in the configure method of a Symfony form to allow the saving of additional fields.</p> <code
lang="php" tab_size="2"> < ?php
// lib/form/MyModelForm.class.php
public function configure() {
$this->validatorSchema->setOption('allow_extra_fields', true);
}
?> </code>Related posts:<ol><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting Default Values'>Snippet: Symfony Forms &#8211; Setting Default Values</a> <small>I often forget how to set default values for form...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-the-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting the Form Formatter'>Snippet: Symfony Forms &#8211; Setting the Form Formatter</a> <small>By default Symfony displays forms in tables, with each new...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-definition-list-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Definition List Form Formatter'>Snippet: Symfony Forms &#8211; Definition List Form Formatter</a> <small>Back in April I posted a Snippet on Symfony Form...</small></li></ol>]]></description> <content:encoded><![CDATA[<p>Place this line of code in the configure method of a Symfony form to allow the saving of additional fields. This is used when additional information or inputs are needed in the form which are not saved in their own fields in the database. Examples are data which might be serialized into an array and stored in a single field, or when uploading multiple files but only saving one reference or filename.</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
/></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; <span
style="color: #666666; font-style: italic;">// lib/form/MyModelForm.class.php </span><br
/> &nbsp; <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><br
/> &nbsp; &nbsp; <span
style="color: #000088;">$this</span><span
style="color: #339933;">-&gt;</span><span
style="color: #004000;">validatorSchema</span><span
style="color: #339933;">-&gt;</span><span
style="color: #004000;">setOption</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">'allow_extra_fields'</span><span
style="color: #339933;">,</span> <span
style="color: #009900; font-weight: bold;">true</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>When using extra fields you will need to override the doSave() or save() method of the form and process the additional values to allow the form to save successfully.</p><p
class="small"><strong>A Note on Snippets:</strong> When using frameworks such as Symfony it is often the simplest pieces of code which are the hardest to either find or remember. These snippets are placed here for my own reference and will hopefully be useful to others. If you find them useful or have any suggestions, let me know.</p><p>Related posts:<ol><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-default-values' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting Default Values'>Snippet: Symfony Forms &#8211; Setting Default Values</a> <small>I often forget how to set default values for form...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-setting-the-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Setting the Form Formatter'>Snippet: Symfony Forms &#8211; Setting the Form Formatter</a> <small>By default Symfony displays forms in tables, with each new...</small></li><li><a
href='http://erisds.co.uk/symfony/snippet-symfony-forms-definition-list-form-formatter' rel='bookmark' title='Permanent Link: Snippet: Symfony Forms &#8211; Definition List Form Formatter'>Snippet: Symfony Forms &#8211; Definition List Form Formatter</a> <small>Back in April I posted a Snippet on Symfony Form...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://erisds.co.uk/symfony/snippet-symfony-forms-allowing-extra-fields/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
<!-- This site's performance optimized by W3 Total Cache. Dramatically improve the speed and reliability of your blog!

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)
Database Caching 34/141 queries in 0.149 seconds using disk

Served from: DSX4001-21.guardiandns.com @ 2010-02-09 00:08:04 -->