<?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: Creating Usable Forms With Zend Framework</title>
	<atom:link href="http://www.littlehart.net/atthekeyboard/2010/01/27/creating-usable-forms-with-zend-framework/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.littlehart.net/atthekeyboard/2010/01/27/creating-usable-forms-with-zend-framework/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
	<description>Facebook should&#039;ve be written in unicornSchemaLang, because everyone *knows* that PHP is no good for anything, right?</description>
	<lastBuildDate>Fri, 30 Jul 2010 05:30:02 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Derek Martin</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/01/27/creating-usable-forms-with-zend-framework/comment-page-1/#comment-15387</link>
		<dc:creator>Derek Martin</dc:creator>
		<pubDate>Wed, 10 Feb 2010 20:57:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=653#comment-15387</guid>
		<description>A little trick. To reduce repetition, you can create your own Action like this:

abstract class My_Controller_Action extends Zend_Controller_Action
{

}
   public function init()
   {
        $this-&gt;_flashMessenger = $this-&gt;_helper-&gt;getHelper(&#039;FlashMessenger&#039;);
        $this-&gt;initView();
    }


THEN all you have to do is:

class Admin_LeaguesController extends My_Controller_Action

and you&#039;ll have the FlashMessenger automatically working in all controllers that extend My_Controller_Action.

I also do my ACL checks in My_Controller_Action&#039;s init()</description>
		<content:encoded><![CDATA[<p>A little trick. To reduce repetition, you can create your own Action like this:</p>
<p>abstract class My_Controller_Action extends Zend_Controller_Action<br />
{</p>
<p>}<br />
   public function init()<br />
   {<br />
        $this-&gt;_flashMessenger = $this-&gt;_helper-&gt;getHelper(&#8216;FlashMessenger&#8217;);<br />
        $this-&gt;initView();<br />
    }</p>
<p>THEN all you have to do is:</p>
<p>class Admin_LeaguesController extends My_Controller_Action</p>
<p>and you&#8217;ll have the FlashMessenger automatically working in all controllers that extend My_Controller_Action.</p>
<p>I also do my ACL checks in My_Controller_Action&#8217;s init()</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Lima</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/01/27/creating-usable-forms-with-zend-framework/comment-page-1/#comment-15299</link>
		<dc:creator>Daniel Lima</dc:creator>
		<pubDate>Wed, 03 Feb 2010 17:43:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=653#comment-15299</guid>
		<description>Hi Charles, 
Great article!
To apply decorator to ALL form elements, i recommend use Plugin Loaders. 

Create your own plugin, and add it to the form or form class.

&lt;code&gt;
$form-&gt;addElementPrefixPath(&#039;My_Decorator&#039;, &#039;My/Decorator/&#039;, &#039;decorator&#039;);
&lt;/code&gt;
See more in http://framework.zend.com/manual/en/zend.form.elements.html#zend.form.elements.loaders

Thanks!</description>
		<content:encoded><![CDATA[<p>Hi Charles,<br />
Great article!<br />
To apply decorator to ALL form elements, i recommend use Plugin Loaders. </p>
<p>Create your own plugin, and add it to the form or form class.</p>
<p><code><br />
$form-&gt;addElementPrefixPath('My_Decorator', 'My/Decorator/', 'decorator');<br />
</code><br />
See more in <a href="http://framework.zend.com/manual/en/zend.form.elements.html#zend.form.elements.loaders" rel="nofollow">http://framework.zend.com/manual/en/zend.form.elements.html#zend.form.elements.loaders</a></p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dmitri</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/01/27/creating-usable-forms-with-zend-framework/comment-page-1/#comment-15227</link>
		<dc:creator>Dmitri</dc:creator>
		<pubDate>Sat, 30 Jan 2010 23:15:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=653#comment-15227</guid>
		<description>Great tutorial, thank you!
Small note: $form-&gt;isValid($formData) already populates form with data, so $form-&gt;populate() in your code is redundant.</description>
		<content:encoded><![CDATA[<p>Great tutorial, thank you!<br />
Small note: $form-&gt;isValid($formData) already populates form with data, so $form-&gt;populate() in your code is redundant.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Max&#8217; Lesestoff zum Wochenende &#124; PHP hates me - Der PHP Blog</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/01/27/creating-usable-forms-with-zend-framework/comment-page-1/#comment-15218</link>
		<dc:creator>Max&#8217; Lesestoff zum Wochenende &#124; PHP hates me - Der PHP Blog</dc:creator>
		<pubDate>Sat, 30 Jan 2010 06:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=653#comment-15218</guid>
		<description>[...] Versionskontrolle mit GIT   LackRack &#8211; Eth0Wiki Ein Server-Rack kostengünstig produziert     @TheKeyboard » Blog Archive » Creating Usable Forms With Zend Framework Wie man Zend_Form Formulare ein bisschen mehr wiederbenutzbarer gestalten.   Ruby-like iterators in [...]</description>
		<content:encoded><![CDATA[<p>[...] Versionskontrolle mit GIT   LackRack &#8211; Eth0Wiki Ein Server-Rack kostengünstig produziert     @TheKeyboard » Blog Archive » Creating Usable Forms With Zend Framework Wie man Zend_Form Formulare ein bisschen mehr wiederbenutzbarer gestalten.   Ruby-like iterators in [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Hartjes</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/01/27/creating-usable-forms-with-zend-framework/comment-page-1/#comment-15205</link>
		<dc:creator>Chris Hartjes</dc:creator>
		<pubDate>Fri, 29 Jan 2010 21:40:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=653#comment-15205</guid>
		<description>@Jo - Yeah, I searched around for some &quot;Zend Framework best practices&quot; and found the return after redirect trick.

@Vika - I&#039;ll switch up to use init(), just going based on some existing samples but always willing to learn the proper way to do things.

@Matthew Thanks for the tips as well</description>
		<content:encoded><![CDATA[<p>@Jo &#8211; Yeah, I searched around for some &#8220;Zend Framework best practices&#8221; and found the return after redirect trick.</p>
<p>@Vika &#8211; I&#8217;ll switch up to use init(), just going based on some existing samples but always willing to learn the proper way to do things.</p>
<p>@Matthew Thanks for the tips as well</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew Turland</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/01/27/creating-usable-forms-with-zend-framework/comment-page-1/#comment-15204</link>
		<dc:creator>Matthew Turland</dc:creator>
		<pubDate>Fri, 29 Jan 2010 21:07:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=653#comment-15204</guid>
		<description>There is actually another option for adding elements: Zend_Form::addElements() using a single array. It&#039;s just not very well documented; you have to dig in the API docs and source code to find it. I actually like that approach because adding a new element only requires adding a new array entry and keeps code to create and use the form fairly minimal.

Also, just FYI, there&#039;s an init() stub in Zend_Form that you can override for initialization code. This alleviates the need to override the constructor and explicitly call the parent constructor. Makes code a bit cleaner and removes the possibility of forgetting to include the parent constructor call causing issues. To handle your custom leagueId option, I probably would suggest overriding setOptions(), handle checking for it and applying the related form change there, and then calling parent::setOptions($options). That way, no matter where the option is set from ($options to the constructor or a subsequent setOptions() call), the intended effect still occurs.

With regards to adding decorators to all form elements, I don&#039;t think there&#039;s a way to do this aside from looping over all elements and calling addDecorator() on each one. There&#039;s a ticket in JIRA for a similar feature for applying decorators, filters, and validators if you&#039;d like to comment or vote on it: http://framework.zend.com/issues/browse/ZF-3945</description>
		<content:encoded><![CDATA[<p>There is actually another option for adding elements: Zend_Form::addElements() using a single array. It&#8217;s just not very well documented; you have to dig in the API docs and source code to find it. I actually like that approach because adding a new element only requires adding a new array entry and keeps code to create and use the form fairly minimal.</p>
<p>Also, just FYI, there&#8217;s an init() stub in Zend_Form that you can override for initialization code. This alleviates the need to override the constructor and explicitly call the parent constructor. Makes code a bit cleaner and removes the possibility of forgetting to include the parent constructor call causing issues. To handle your custom leagueId option, I probably would suggest overriding setOptions(), handle checking for it and applying the related form change there, and then calling parent::setOptions($options). That way, no matter where the option is set from ($options to the constructor or a subsequent setOptions() call), the intended effect still occurs.</p>
<p>With regards to adding decorators to all form elements, I don&#8217;t think there&#8217;s a way to do this aside from looping over all elements and calling addDecorator() on each one. There&#8217;s a ticket in JIRA for a similar feature for applying decorators, filters, and validators if you&#8217;d like to comment or vote on it: <a href="http://framework.zend.com/issues/browse/ZF-3945" rel="nofollow">http://framework.zend.com/issues/browse/ZF-3945</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vika</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/01/27/creating-usable-forms-with-zend-framework/comment-page-1/#comment-15201</link>
		<dc:creator>Vika</dc:creator>
		<pubDate>Fri, 29 Jan 2010 19:31:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=653#comment-15201</guid>
		<description>It&#039;s probably not the best idea to override __construct in Zend_Form, since you&#039;re calling parent::__construct anyway. A better approach would be to override Zend_Form::init() - this one gets called in constructor and, according to ZF docs, should be used for extending classes. And yes, this just looks cleaner.
Besides, you don&#039;t really need to deal with this $options array. Cause whichever array you pass to the form constructor, it gets immediately accessible in form through $this-&gt;_attribs. 
So, in your case you should be able to use $this-&gt;_attribs[&#039;action&#039;] instead of $options[&#039;action&#039;].</description>
		<content:encoded><![CDATA[<p>It&#8217;s probably not the best idea to override __construct in Zend_Form, since you&#8217;re calling parent::__construct anyway. A better approach would be to override Zend_Form::init() &#8211; this one gets called in constructor and, according to ZF docs, should be used for extending classes. And yes, this just looks cleaner.<br />
Besides, you don&#8217;t really need to deal with this $options array. Cause whichever array you pass to the form constructor, it gets immediately accessible in form through $this-&gt;_attribs.<br />
So, in your case you should be able to use $this-&gt;_attribs['action'] instead of $options['action'].</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jo</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/01/27/creating-usable-forms-with-zend-framework/comment-page-1/#comment-15200</link>
		<dc:creator>Jo</dc:creator>
		<pubDate>Fri, 29 Jan 2010 18:36:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=653#comment-15200</guid>
		<description>You can use $this-&gt;setElementDecorators($decorators, $elements, $exclusionsFlag) inside the form class to set one style for all elements. The second and third parameter help to set exceptions, say for buttons, etc.

As a side note rather than have an exit after a redirect do this:
return $this-&gt;_redirect(&#039;/admin&#039;); 

Once you come to do some unit testing etc, it&#039;s going to save you some hassle.

Back to forms, if you have more than one or two in your application it is worth creating your own class that extends Zend_Form, and using this for you individual form classes. You will find a lot of things repeating that can be nicely abstracted across several forms.</description>
		<content:encoded><![CDATA[<p>You can use $this-&gt;setElementDecorators($decorators, $elements, $exclusionsFlag) inside the form class to set one style for all elements. The second and third parameter help to set exceptions, say for buttons, etc.</p>
<p>As a side note rather than have an exit after a redirect do this:<br />
return $this-&gt;_redirect(&#8216;/admin&#8217;); </p>
<p>Once you come to do some unit testing etc, it&#8217;s going to save you some hassle.</p>
<p>Back to forms, if you have more than one or two in your application it is worth creating your own class that extends Zend_Form, and using this for you individual form classes. You will find a lot of things repeating that can be nicely abstracted across several forms.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kenrick</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/01/27/creating-usable-forms-with-zend-framework/comment-page-1/#comment-15198</link>
		<dc:creator>kenrick</dc:creator>
		<pubDate>Fri, 29 Jan 2010 15:11:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=653#comment-15198</guid>
		<description>sorry it stripped out the html in my above example, it just had tr/td elements in it.</description>
		<content:encoded><![CDATA[<p>sorry it stripped out the html in my above example, it just had tr/td elements in it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kenrick</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/01/27/creating-usable-forms-with-zend-framework/comment-page-1/#comment-15197</link>
		<dc:creator>kenrick</dc:creator>
		<pubDate>Fri, 29 Jan 2010 15:10:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=653#comment-15197</guid>
		<description>my favorite part for sure of the zend framework has to be zend form. while its not always the best choice for some forms - like those one off forms that require a special layout etc.- the reusability of the forms make them awesome. I find myself using removeElement alot too, if there only needs to be one thing different about the form for it to be used in another part of the application, just modify that one form and boom, done much faster.

the decorators are still the voodoo magic part, and I have had alot of frustration with them to get them to work the way I want. it would be so much nicer to be able to pass a small html template with placeholders instead of trying to figure out the decorator chain.

like form-&gt;my_element-&gt;setTemplate(&#039;{label}{element}&#039;);

sometimes design patterns are too fancy for their own good.</description>
		<content:encoded><![CDATA[<p>my favorite part for sure of the zend framework has to be zend form. while its not always the best choice for some forms &#8211; like those one off forms that require a special layout etc.- the reusability of the forms make them awesome. I find myself using removeElement alot too, if there only needs to be one thing different about the form for it to be used in another part of the application, just modify that one form and boom, done much faster.</p>
<p>the decorators are still the voodoo magic part, and I have had alot of frustration with them to get them to work the way I want. it would be so much nicer to be able to pass a small html template with placeholders instead of trying to figure out the decorator chain.</p>
<p>like form-&gt;my_element-&gt;setTemplate(&#8216;{label}{element}&#8217;);</p>
<p>sometimes design patterns are too fancy for their own good.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
