<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Improving the Forms</title>
	<atom:link href="http://webmozarts.com/2009/04/12/improving-the-forms/feed/" rel="self" type="application/rss+xml" />
	<link>http://webmozarts.com/2009/04/12/improving-the-forms/</link>
	<description>On The Art Of Web Development</description>
	<lastBuildDate>Mon, 30 Aug 2010 03:06:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Gijs Nelissen</title>
		<link>http://webmozarts.com/2009/04/12/improving-the-forms/comment-page-1/#comment-434</link>
		<dc:creator>Gijs Nelissen</dc:creator>
		<pubDate>Thu, 27 Aug 2009 10:50:17 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=161#comment-434</guid>
		<description>One of the most interesting symfony articles i&#039;ve seen in awhile.
Glad you joined the core team ! Very good idea&#039;s &amp; input !</description>
		<content:encoded><![CDATA[<p>One of the most interesting symfony articles i&#8217;ve seen in awhile.<br />
Glad you joined the core team ! Very good idea&#8217;s &amp; input !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Indra</title>
		<link>http://webmozarts.com/2009/04/12/improving-the-forms/comment-page-1/#comment-373</link>
		<dc:creator>Indra</dc:creator>
		<pubDate>Sat, 01 Aug 2009 18:38:17 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=161#comment-373</guid>
		<description>The flexibity provided by symfony forms are great but the problem is exposure to too much internal detail of forms and, at times, somewhat incoherent API. 

My first set of recommendations will be as follows:
1)Make sure user of the framework can&#039;t access widgetSchema or validatorSchema from sfForm.
2)Add methods, that user will call on widgetSchema or validatorSchema, to the form class itself. Examples are setLabel, setLabels, setOption, setOptions, setAttribute, setAttributes etc.
3)May be we should not even have a setPostValidator method. Its syntax is unnecessarily complex. Instead add a method to the form class named postValidate.
4)Add addField method to sfForm which takes the name of the field and returns an sfFormField which can be customized. See example below.
 
If we create a new class everytime we want to customize a form field, we might end up creating many small classes in our application. This may or may not be a problem depending on the number of classes you will have to create and maintain. However, I see that method chaining is a great idea. I would propose something like this which I have used in other (nonPHP) frameworks:

$this-&gt;addField( &#039;first_name&#039; )
     -&gt;setWidget( new sfWidgetInput() )
     -&gt;setOption( &#039;required&#039;, true )
     -&gt;setOption( &#039;max_length&#039;, 50 )
     -&gt;setAttribute( &#039;columns&#039;, 20 )
     -&gt;setAttribute( &#039;style&#039;, &#039;background:grey&#039; )
     -&gt;addValidator( ... )
     -&gt;addValidator( ... );
     
$this-&gt;addField( &#039;last_name&#039; )
     -&gt;setWidget( new sfWidgetInput() )
     -&gt;setOptions( array( &#039;required&#039;=&gt; false, &#039;max_length&#039; =&gt; 20) )
     -&gt;setAttributes( array( &#039;columns&#039; =&gt; 20, &#039;style&#039; =&gt; &#039;background:grey&#039; ) )
     -&gt;addValidators( ... );

- Indra</description>
		<content:encoded><![CDATA[<p>The flexibity provided by symfony forms are great but the problem is exposure to too much internal detail of forms and, at times, somewhat incoherent API. </p>
<p>My first set of recommendations will be as follows:<br />
1)Make sure user of the framework can&#8217;t access widgetSchema or validatorSchema from sfForm.<br />
2)Add methods, that user will call on widgetSchema or validatorSchema, to the form class itself. Examples are setLabel, setLabels, setOption, setOptions, setAttribute, setAttributes etc.<br />
3)May be we should not even have a setPostValidator method. Its syntax is unnecessarily complex. Instead add a method to the form class named postValidate.<br />
4)Add addField method to sfForm which takes the name of the field and returns an sfFormField which can be customized. See example below.</p>
<p>If we create a new class everytime we want to customize a form field, we might end up creating many small classes in our application. This may or may not be a problem depending on the number of classes you will have to create and maintain. However, I see that method chaining is a great idea. I would propose something like this which I have used in other (nonPHP) frameworks:</p>
<p>$this-&gt;addField( &#8216;first_name&#8217; )<br />
     -&gt;setWidget( new sfWidgetInput() )<br />
     -&gt;setOption( &#8216;required&#8217;, true )<br />
     -&gt;setOption( &#8216;max_length&#8217;, 50 )<br />
     -&gt;setAttribute( &#8216;columns&#8217;, 20 )<br />
     -&gt;setAttribute( &#8217;style&#8217;, &#8216;background:grey&#8217; )<br />
     -&gt;addValidator( &#8230; )<br />
     -&gt;addValidator( &#8230; );</p>
<p>$this-&gt;addField( &#8216;last_name&#8217; )<br />
     -&gt;setWidget( new sfWidgetInput() )<br />
     -&gt;setOptions( array( &#8216;required&#8217;=&gt; false, &#8216;max_length&#8217; =&gt; 20) )<br />
     -&gt;setAttributes( array( &#8216;columns&#8217; =&gt; 20, &#8217;style&#8217; =&gt; &#8216;background:grey&#8217; ) )<br />
     -&gt;addValidators( &#8230; );</p>
<p>- Indra</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete BD</title>
		<link>http://webmozarts.com/2009/04/12/improving-the-forms/comment-page-1/#comment-313</link>
		<dc:creator>Pete BD</dc:creator>
		<pubDate>Mon, 13 Jul 2009 10:13:03 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=161#comment-313</guid>
		<description>@Bernard:  It makes even more sense now that I read about the sfFormFieldGroup class.  You can drop the setFormValidator altogether and just have setValidator in the sfFormFieldInterface
using it either at the field level, the field group level or the form level.</description>
		<content:encoded><![CDATA[<p>@Bernard:  It makes even more sense now that I read about the sfFormFieldGroup class.  You can drop the setFormValidator altogether and just have setValidator in the sfFormFieldInterface<br />
using it either at the field level, the field group level or the form level.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete BD</title>
		<link>http://webmozarts.com/2009/04/12/improving-the-forms/comment-page-1/#comment-312</link>
		<dc:creator>Pete BD</dc:creator>
		<pubDate>Mon, 13 Jul 2009 10:04:00 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=161#comment-312</guid>
		<description>@klemens: You could actually make this shorter still with

this-&gt;addField(’name’, new sfFieldString())
-&gt;setMaxLength(15);

Since addField returns the new sfFieldString() object you can call methods on it that are specific to its purpose.</description>
		<content:encoded><![CDATA[<p>@klemens: You could actually make this shorter still with</p>
<p>this-&gt;addField(’name’, new sfFieldString())<br />
-&gt;setMaxLength(15);</p>
<p>Since addField returns the new sfFieldString() object you can call methods on it that are specific to its purpose.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernhard</title>
		<link>http://webmozarts.com/2009/04/12/improving-the-forms/comment-page-1/#comment-311</link>
		<dc:creator>Bernhard</dc:creator>
		<pubDate>Mon, 13 Jul 2009 10:03:55 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=161#comment-311</guid>
		<description>@Pete: Ad 2: This is actually a great idea! Thank you for your feedback.</description>
		<content:encoded><![CDATA[<p>@Pete: Ad 2: This is actually a great idea! Thank you for your feedback.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete BD</title>
		<link>http://webmozarts.com/2009/04/12/improving-the-forms/comment-page-1/#comment-310</link>
		<dc:creator>Pete BD</dc:creator>
		<pubDate>Mon, 13 Jul 2009 10:00:15 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=161#comment-310</guid>
		<description>Really great ideas.  You are absolutely right that symfony needs to have a self-evident class library.  There should be little or no need to consult a reference text to work out how to do something.  This is especially true of PHP type languages where auto-completion is not completely reliable.

Two really simple (and aesthetic) suggestions:

1) Personally I prefer to use &quot;readonly=true&quot; rather than &quot;editable=false&quot;.  It just reads :-) better.

2) I find the &quot;final&quot; in setFinalValidator no better than &quot;post&quot;.  It still makes me think.  Why not realise that what you are saying is that there are two kinds of validators: field validators that are specific to individual fields and form validators that are for the form as a whole?  The only reason one needs to have &quot;post&quot; or &quot;final&quot; on the front of this method call is because at the moment all the validators are conceptually stored in the form.  With your new sfField objects holding their own validators you can just have a setValidator method on the sfForm class or maybe setFormValidator if you must.</description>
		<content:encoded><![CDATA[<p>Really great ideas.  You are absolutely right that symfony needs to have a self-evident class library.  There should be little or no need to consult a reference text to work out how to do something.  This is especially true of PHP type languages where auto-completion is not completely reliable.</p>
<p>Two really simple (and aesthetic) suggestions:</p>
<p>1) Personally I prefer to use &#8220;readonly=true&#8221; rather than &#8220;editable=false&#8221;.  It just reads <img src='http://webmozarts.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  better.</p>
<p>2) I find the &#8220;final&#8221; in setFinalValidator no better than &#8220;post&#8221;.  It still makes me think.  Why not realise that what you are saying is that there are two kinds of validators: field validators that are specific to individual fields and form validators that are for the form as a whole?  The only reason one needs to have &#8220;post&#8221; or &#8220;final&#8221; on the front of this method call is because at the moment all the validators are conceptually stored in the form.  With your new sfField objects holding their own validators you can just have a setValidator method on the sfForm class or maybe setFormValidator if you must.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Klemens</title>
		<link>http://webmozarts.com/2009/04/12/improving-the-forms/comment-page-1/#comment-288</link>
		<dc:creator>Klemens</dc:creator>
		<pubDate>Wed, 08 Jul 2009 08:10:02 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=161#comment-288</guid>
		<description>sfField could have generic options. Example: setting the max_length of your &quot;name&quot; field isn&#039;t DRY.

It could look like this:
$this-&gt;addField(&#039;name&#039;, new sfFieldString())
    -&gt;setOption(&#039;max_length&#039;, 15)
;

sfFieldString would then parse the generic option and set the appropriate Options for widget and string.</description>
		<content:encoded><![CDATA[<p>sfField could have generic options. Example: setting the max_length of your &#8220;name&#8221; field isn&#8217;t DRY.</p>
<p>It could look like this:<br />
$this-&gt;addField(&#8216;name&#8217;, new sfFieldString())<br />
    -&gt;setOption(&#8216;max_length&#8217;, 15)<br />
;</p>
<p>sfFieldString would then parse the generic option and set the appropriate Options for widget and string.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olivier Pichon</title>
		<link>http://webmozarts.com/2009/04/12/improving-the-forms/comment-page-1/#comment-167</link>
		<dc:creator>Olivier Pichon</dc:creator>
		<pubDate>Thu, 11 Jun 2009 09:46:30 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=161#comment-167</guid>
		<description>Very interesting approach. I definitely look forward to an early release of any code, even at prototype stage. I could also contribute.

What about yaml form configuration ? 

I am not arguing for a 100% coverage of form config via yaml -- that&#039;s possibly impossible and definitely a wast of effort.

However, for most forms, I&#039;m pretty sure that the degree of customization is mostly a matter of reconfiguring the order of fields, possibly re-arranging them in groups, etc. All of which is simply a recombination of existing framework constructs: fields, formatters, layouts, widgets, etc. A yaml config file would then be perfectly suitable. More complex form customization could  of course still be handled by extending classes, etc.

I would think therefore that allowing form definition via a yaml config file would be beneficial in quite a large number of situations.  While this feature is not definitely not a must-have initially, I tend to think that its feasibility would also provide a strong validation of your concepts. If it&#039;s easy enough to configure in the code, then a yaml configuration should really just be a layer above that logic.</description>
		<content:encoded><![CDATA[<p>Very interesting approach. I definitely look forward to an early release of any code, even at prototype stage. I could also contribute.</p>
<p>What about yaml form configuration ? </p>
<p>I am not arguing for a 100% coverage of form config via yaml &#8212; that&#8217;s possibly impossible and definitely a wast of effort.</p>
<p>However, for most forms, I&#8217;m pretty sure that the degree of customization is mostly a matter of reconfiguring the order of fields, possibly re-arranging them in groups, etc. All of which is simply a recombination of existing framework constructs: fields, formatters, layouts, widgets, etc. A yaml config file would then be perfectly suitable. More complex form customization could  of course still be handled by extending classes, etc.</p>
<p>I would think therefore that allowing form definition via a yaml config file would be beneficial in quite a large number of situations.  While this feature is not definitely not a must-have initially, I tend to think that its feasibility would also provide a strong validation of your concepts. If it&#8217;s easy enough to configure in the code, then a yaml configuration should really just be a layer above that logic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Henrik Bjornskov</title>
		<link>http://webmozarts.com/2009/04/12/improving-the-forms/comment-page-1/#comment-30</link>
		<dc:creator>Henrik Bjornskov</dc:creator>
		<pubDate>Wed, 15 Apr 2009 11:05:33 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=161#comment-30</guid>
		<description>Some of your ideas are indeed nice, and could be implemented but againg too simple is also a problem, and changing the way things are named in symfony is just a too big of a thing to do.

But some of it i am all for :)</description>
		<content:encoded><![CDATA[<p>Some of your ideas are indeed nice, and could be implemented but againg too simple is also a problem, and changing the way things are named in symfony is just a too big of a thing to do.</p>
<p>But some of it i am all for <img src='http://webmozarts.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David&#8217;s virtual world &#187; Blog Archive &#187; Improving the forms even more</title>
		<link>http://webmozarts.com/2009/04/12/improving-the-forms/comment-page-1/#comment-29</link>
		<dc:creator>David&#8217;s virtual world &#187; Blog Archive &#187; Improving the forms even more</dc:creator>
		<pubDate>Tue, 14 Apr 2009 07:38:12 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=161#comment-29</guid>
		<description>[...] 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 [...]</description>
		<content:encoded><![CDATA[<p>[...] 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 [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
