<?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>@TheKeyboard</title>
	<atom:link href="http://www.littlehart.net/atthekeyboard/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.littlehart.net/atthekeyboard</link>
	<description>Facebook should&#039;ve be written in unicornSchemaLang, because everyone *knows* that PHP is no good for anything, right?</description>
	<lastBuildDate>Tue, 16 Mar 2010 15:27:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
			<item>
		<title>Expand your programming mind:  filters in Lithium</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/03/16/expand-your-programming-mind-filters-in-lithium/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2010/03/16/expand-your-programming-mind-filters-in-lithium/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 15:27:17 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[aspect-oriented programming]]></category>
		<category><![CDATA[behaviors]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[callbacks]]></category>
		<category><![CDATA[closures]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[filters]]></category>
		<category><![CDATA[li3]]></category>
		<category><![CDATA[namespaces]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=699</guid>
		<description><![CDATA[Out of the ashes of a severe personality clash in an open source PHP web application framework project rose a new framework proclaiming that it simply sucks less than all the others.  Lithium, otherwise known as li3, is the latest PHP application framework to come onto the scene.  I know what you&#8217;re saying. [...]]]></description>
			<content:encoded><![CDATA[<p>Out of the ashes of a severe personality clash in an <a href="http://cakephp.org">open source PHP web application framework project</a> rose a new framework proclaiming that it <a href="http://rad-dev.org/lithium/wiki">simply sucks less than all the others</a>.  Lithium, otherwise known as li3, is the latest PHP application framework to come onto the scene.  I know what you&#8217;re saying.  *Yawn*.
</p>
<p>
As far as I can tell, Lithium is trying it&#8217;s hardest to be fast, lightweight, and use all the features that PHP 5.3 has to offer.  I am unable to use it at work for a variety of reasons (not stable, required PHP 5.3 only, <a href="http://twitter.com/nateabele">Nate</a> is always picking on me via IM) but I am more interested in the ideas that are coming out of it.
</p>
<p>
It is using all the newest hawtness in the PHP world:  namespaces, closures, Phar, late static binding.  I could go on, but probably most of these things mean nothing to you until you actually need them.  In the framework world, namespaces are a big deal, an essential tool to avoiding collisions with 3rd party code you might want to integrate into your project.  Closures are very familiar to those who&#8217;ve done work with Ruby or Javascript.  Phar allows for some unarchiving on the fly of code, even potentially distributing your application as an archive that can be run.  Late static binding is something I&#8217;m trying to comes to grips with, as I have either never come across a need for it or never realized that I did and have implemented a workaround for it not realizing there is a simpler solution.
</p>
<p>
None of these are what I want to talk about.  I want to talk about something that I feel is a very underrated part of Lithium, the ability to define filters.  This is a concept that you find in <a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">Aspect-oriented programming</a>, and one that I imagine most programmers have never considered.  Here&#8217;s why I think it&#8217;s a big deal.
</p>
<p>
Most frameworks are designed around an OOP paradigm.  Yes, some mix them together (I&#8217;m looking at *you* CodeIgniter), but by and large you get the job done by extending on a base model / controller / helper / whatever to create new functionality.  Sometimes this is not avoidable.  But what AOP says is that there is another way, a way that Lithium has adopted as well.
</p>
<p>
Hence the creation of &#8220;filters&#8221;.  As far as I can tell (and I&#8217;m sure I will be jumped upon if I am wrong) the purpose of filters in Lithium is to allow you to add functionality without extending the class itself.  When I saw that I immediately understood why that is so awesome.
</p>
<p>
The idea of callbacks is also very similar:  if X happens, run code Y.  A staple of jQuery, Rails and probably other projects I have forgotten to mention.  The idea is still the same though.  In Garrett Woodworth&#8217;s <a href="http://www.slideshare.net/gwoo/li3-ocphp">presentation about Lithium to the Orange County PHP Users Group</a> he goes  over some solid examples of filters including:</p>
<ul>
<li>automatic use of the <a href="http://mirror.facebook.net/facebook/xhprof/doc.html">XHProf</a> for code profiling</li>
<li>automatic setting of parameters upon saving a pasted bit of code</li>
</ul>
<p>It&#8217;s also been used to <a href="http://misja.posterous.com/playing-with-lithium">automatically change string record ID&#8217;s into a MongoDB ID</a> and <a href="http://latestatic.com/integration-testing-or-how-i-learned-to-stop">graceful failing of an integration test suite when an error occurs</a>.
</p>
<p>
These filters remind me of behaviors in Rails (and in CakePHP as well) and makes me wonder if signals are the same thing in the Django world.  All in all, this looks to me to be a better way to extend functionality than actually overriding existing methods or hacking at something deep inside a class.  Figure out what functionality you want, figure out where it needs to be called, and add your filter.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2010/03/16/expand-your-programming-mind-filters-in-lithium/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Rallyhat lives!</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/03/12/rallyhat-lives/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2010/03/12/rallyhat-lives/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 22:00:58 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Rallyhat]]></category>
		<category><![CDATA[CouchDB]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Django Debug Toolbar]]></category>
		<category><![CDATA[django-registration]]></category>
		<category><![CDATA[Eric Florenzano]]></category>
		<category><![CDATA[geopy]]></category>
		<category><![CDATA[Gunicorn]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=694</guid>
		<description><![CDATA[
Some of my long-time readers have seen me mention a long-festering (I believe that is the correct term at this point) project that I dubbed Rallyhat.  It first started out as a &#8220;figure out when some baseball teams are in town and buy tickets&#8221; and then morphed into &#8220;a tool for helping people plan [...]]]></description>
			<content:encoded><![CDATA[<p>
Some of my long-time readers have seen me mention a long-festering (I believe that is the correct term at this point) project that I dubbed <a href="http://www.rallyhat.com">Rallyhat</a>.  It first started out as a &#8220;figure out when some baseball teams are in town and buy tickets&#8221; and then morphed into &#8220;a tool for helping people plan road trips by tagging destinations with information&#8221;.
</p>
<p>
What it really became was a tool for me to learn how to write a solid web-app using Python and Django.  I&#8217;m happy to say I finally have a version that I feel comfortable sharing with the rest of you.  So feel free to check it out.  Pound on it, try and break it and I will also read your feedback and comments.  I&#8217;m sure you can figure out my email address&#8230;
</p>
<p>
Also, I&#8217;ve found it has been easy to pick up not only Python and Django itself.  I&#8217;m ready to tackle some other applications using Django, and I have one just in mind.
</p>
<p>
Yes, I am aware at how spartan it looks right now.  I&#8217;m more focussed on functionality than how it looks right now.  I&#8217;ve already gotten some interesting ideas on expanding the app to include adding in images to go with locations, so we&#8217;ll see how that goes.
</p>
<p>
For those who are curious, I built it using the following:</p>
<ul>
<li>Python 2.6</li>
<li>Django 1.2 beta 1</li>
<li><a href="http://couchdb.apache.org/">CouchDB</a> to store the trip plans</li>
<li><a href="http://code.google.com/p/couchdb-python/">couchdb-python</a></li>
<li><a href="http://code.google.com/p/geopy/">GeoPy</a></li>
<li><a href="http://bitbucket.org/ubernostrum/django-registration/">django-registration</a></li>
<li>Google Maps services</li>
<li><a href="http://github.com/robhudson/django-debug-toolbar">Django Debug Toolbar</a></li>
<li>deployed using Nginx + <a href="http://github.com/benoitc/gunicorn">Gunicorn</a>, configured with the help of <a href="http://twitter.com/ericlo">Eric Florenzano&#8217;s</a> awesome Django Advent article about <a href="http://djangoadvent.com/1.2/deploying-django-site-using-fastcgi/">deploying Django using FastCGI</a> because it mentioned how you could use Gunicorn</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2010/03/12/rallyhat-lives/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>People Who Make Me Feel Stupid: Fabien Potencier</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/03/05/people-who-make-me-feel-stupid-fabien-potencier/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2010/03/05/people-who-make-me-feel-stupid-fabien-potencier/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 16:02:28 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[Fabien Portencier]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[PHPUnit]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=690</guid>
		<description><![CDATA[This is the final in a series of blog posts about programmers who make me feel stupid due to the amazing work they&#8217;ve done and their ability to explain it.  Check out my thoughts on Geoffrey Grosenbach, Antirez, Rich Hickey and Ezra Zygmuntowicz.
I am, for lack of a better phrase, a framework whore.  [...]]]></description>
			<content:encoded><![CDATA[<p><i>This is the final in a series of blog posts about programmers who make me feel stupid due to the amazing work they&#8217;ve done and their ability to explain it.  Check out my thoughts on <a href="http://www.littlehart.net/atthekeyboard/2010/03/01/people-who-make-me-feel-stupid-geoffrey-grosenbach/">Geoffrey Grosenbach</a>, <a href="http://www.littlehart.net/atthekeyboard/2010/03/02/people-who-make-me-feel-stupid-antirez/">Antirez</a>, <a href="http://www.littlehart.net/atthekeyboard/2010/03/03/people-who-make-me-feel-stupid-rich-hickey/">Rich Hickey</a> and <a href="http://www.littlehart.net/atthekeyboard/2010/03/04/people-who-make-me-feel-stupid-ezra-zygmuntowicz/">Ezra Zygmuntowicz.</a></i></p>
<p>I am, for lack of a better phrase, a framework whore.  I use frameworks to build all my web applications.  Why?  Because I prefer to stand on the shoulder of giants rather than constantly reinvent things.  But in many ways, my addiction to frameworks is counter-productive because I find myself constantly wanting to use a new one.  So I end up churning instead of pushing forwards.   I&#8217;ve been learning Zend Framework, and I&#8217;m struggling.  Too many ways to do things, too much documentation that provides me with a tease of what it is I&#8217;m trying to do but not the full solution.  Then I have to ask people for help and feel stupid for not being the Rock Star Developer(tm) with all the answers.
</p>
<p>
So, even though I use Zend Framework now (unless I change my mind, get pissed off and go with the <a href="http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html">no-framework framework</a>) I do watch other frameworks.  While I might not agree with some features of <a href="http://www.symfony-project.org/">Symfony</a>, I am astounded at what <a href="http://fabien.potencier.org/">Fabien Potencier</a> continues to produce.
</p>
<p>
Creating a framework is an achievement in itself.  Creating a framework in a language as your first real PHP project, like Fabien did, is nothing short of amazing.  Symfony is a full-stack framework, the kind of comfy and warm blanket I like to use when building an application on a short timeline.  Like many other full-stack frameworks, they also wrote stuff that other people had already written.  It&#8217;s a common thing, everyone goes through the &#8220;not invented here&#8221; phase.  Sometimes, that&#8217;s the only way you learn how to do something.
</p>
<p>
But as Symfony glides smoothly along towards a 2.0 release, imagine the shock of people when they see Fabien talk about how he is going to use parts of Zend Framework in the 2.0 core and dump existing components like their own unit-testing framework in favour of PHPUnit.
</p>
<p>
In the blog post about <a href="http://www.symfony-project.org/blog/2010/03/04/symfony-2-0-and-the-php-ecosystem">decisions about Symfony 2</a>, he mentions the logic surrounding what appears to be a new public philosophy from Symfony: &#8220;Use what&#8217;s out there; realise it sucks; write your own; wait until others suck less; dump your own; use other.&#8221;
</p>
<p>
This is a very refreshing stance for the guiding power of a popular web application framework to take.  It reminds me of when Rails and Merb decided to quit fighting and instead become the same project in Rails 3.  The hater in me thinks that it&#8217;s because Merb was becoming what Rails wanted to be, so kudos to the effort to rework Rails to make it better.  After all, that&#8217;s the goal &#8212; to produce better, faster software.
</p>
<p>
So why does Fabien make me feel stupid:  <b>His constant willingness to do the right thing for his project, even if it means tossing away stuff that spent a long time working on.</b>  Again, just like all the others I&#8217;ve talked about here, he does an amazing job of explaining what he did in a way that makes it obvious.  His thoughts on <a href="http://fabien.potencier.org/article/11/what-is-dependency-injection">dependency injection</a> helped me to understand why it&#8217;s important to consider it when building your applications.  I&#8217;ve written code that uses it and code that does not.  I found it easier to refactor code when I used dependency injection, but that just might be me.
</p>
<p>
Thanks for following this series this week.  I hoped I&#8217;ve exposed you to some people you might not have heard of or known about their work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2010/03/05/people-who-make-me-feel-stupid-fabien-potencier/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>People Who Make Me Feel Stupid: Ezra Zygmuntowicz</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/03/04/people-who-make-me-feel-stupid-ezra-zygmuntowicz/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2010/03/04/people-who-make-me-feel-stupid-ezra-zygmuntowicz/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 14:00:47 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[alternate runtimes]]></category>
		<category><![CDATA[Engine Yard]]></category>
		<category><![CDATA[Ezra Zygmuntowicz]]></category>
		<category><![CDATA[Hip Hop]]></category>
		<category><![CDATA[JRuby]]></category>
		<category><![CDATA[Merb]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Rubinus]]></category>
		<category><![CDATA[virtual machines]]></category>
		<category><![CDATA[YARV]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=686</guid>
		<description><![CDATA[This is the 4th out of 5 blog posts about programmers who I find make me feel stupid when I read what they write or hear them speak.  Stupid because what they say is so obvious I cannot believe I missed it.  See my thoughts on Geoffrey Grosenbach, Antirez and Rich Hickey.


Next up [...]]]></description>
			<content:encoded><![CDATA[<p><i>This is the 4th out of 5 blog posts about programmers who I find make me feel stupid when I read what they write or hear them speak.  Stupid because what they say is so obvious I cannot believe I missed it.  See my thoughts on <a href="http://www.littlehart.net/atthekeyboard/2010/03/01/people-who-make-me-feel-stupid-geoffrey-grosenbach/">Geoffrey Grosenbach</a>, <a href="http://www.littlehart.net/atthekeyboard/2010/03/02/people-who-make-me-feel-stupid-antirez/">Antirez</a> and <a href="http://www.littlehart.net/atthekeyboard/2010/03/03/people-who-make-me-feel-stupid-rich-hickey/">Rich Hickey</a>.</i>
</p>
<p>
Next up is another prominent member of the Ruby community, one that I feel truly deserves the label &#8220;Renaissance Programmer&#8221;.  He is <a href="http://brainspl.at/">Ezra Zygmuntowicz</a>, co-founder of <a href="http://www.engineyard.com">Engine Yard</a>, probably the leader in helping people deploy Rails applications of all shapes and sizes.  Ezra seems to have done it all, from Rails work, to <a href="http://merbivore.com/">Merb</a>, to the Ruby VM <a href="http://rubini.us/">Rubinus</a>.
</p>
<p>
If I remember correctly, I first encountered Ezra and his work (and his awesome last name) during my Ruby on Rails research.  Realizing that Rails was the dominate framework in that space, I wondered what the alternatives were.  That lead me to Merb.  Unfortunately at the time it was not well-documented, so I drifted into other things (like so many other times, I&#8217;m sensing a pattern here).  Then I started hearing about the efforts to create an alternative to the standard Ruby virtual machine, with the goal of creating, I imagine, a faster Ruby environment.
</p>
<p>Much as I cannot imagine writing my own programming language, I could not imagine creating a virtual machine based on running code in an already-established language.  Then I saw <a href="http://www.youtube.com/watch?v=TcMklv40YMY">this talk</a> Ezra gave about Merb, Rubinus and the stack that Engine Yard uses.  What blew me away was when he started explaining *how* he was going about implementing Rubinus.  It made so much sense.
</p>
<p>
See, in the Ruby world you can use what they call Matz&#8217; Ruby Interpreter, or CRuby as a reference point.  Since there is no official spec, the MRI is used.  So if you want to create your own Ruby virtual machine, it&#8217;s as simple as looking at how the MRI implements functionality and then copy it in your own VM.  Repeat until your own virtual machine passes all the tests in the <a href="http://rubyspec.org/">RubySpec</a> project and bingo!  You have a (hopefully as close to compatible with the MRI) virtual machine for running Ruby.  It seems that <a href="http://en.wikipedia.org/wiki/YARV">YARV</a> is a virtual machine (I believe it is a bytecode interpreter) that is included with the latest version of Ruby at this writing, 1.9.
</p>
<p>
So why does Ezra make me feel stupid: <b>He has fully immersed himself in the Ruby world from the virtual machine to the language implementation to frameworks that sit on top of it.  Like most of the people I talk about in this series, he also knows how to explain these things to people in such a way that you do not realize what awesome work he is doing.</b>
</p>
<p>
I may not be doing anything with Ruby any more, but how can you not get interested in the nuts-and-bolts of a language and virtual machines in general when someone like Ezra explains it to you?!?  In the PHP world, Facebook recently announced the release and open sourcing of <a href="http://wiki.github.com/facebook/hiphop-php/">Hip Hop for PHP</a>.  This project takes PHP code, parses it and generates C++ executables.  This is a big deal for Facebook, who is the largest user of PHP out there.  It lets them use approximately 50% fewer servers when delivering PHP-results.  They did the same thing I talked about above:  looked at how PHP implemented functions at the lowest level, and then figured out how to do it in C++.  It&#8217;s a very unique project, and obviously not for everyone.  But again, an awesome case study on creating virtual machines / alternate runtimes for an existing programming language.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2010/03/04/people-who-make-me-feel-stupid-ezra-zygmuntowicz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>People Who Make Me Feel Stupid: Rich Hickey</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/03/03/people-who-make-me-feel-stupid-rich-hickey/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2010/03/03/people-who-make-me-feel-stupid-rich-hickey/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 14:00:06 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[Clojure]]></category>
		<category><![CDATA[concurrency]]></category>
		<category><![CDATA[event-driven programming]]></category>
		<category><![CDATA[JVM]]></category>
		<category><![CDATA[Rich Hickey]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=680</guid>
		<description><![CDATA[This is the third in a series of blog posts where I talk about people who&#8217;s skills as programmers make me feel stupid.  Check out my thoughts on Geoffrey Grosenbach and Antirez.


As a person who learned the hard way about how tough it is creating web applications that can handle state and concurrency  [...]]]></description>
			<content:encoded><![CDATA[<p><i>This is the third in a series of blog posts where I talk about people who&#8217;s skills as programmers make me feel stupid.  Check out my thoughts on <a href="http://www.littlehart.net/atthekeyboard/2010/03/01/people-who-make-me-feel-stupid-geoffrey-grosenbach/">Geoffrey Grosenbach</a> and <a href="http://www.littlehart.net/atthekeyboard/2010/03/02/people-who-make-me-feel-stupid-antirez/">Antirez</a>.</i>
</p>
<p>
As a person who learned the hard way about how tough it is creating web applications that can handle state and concurrency  issues (if you&#8217;ve ever seen MySQL replication lag times as high as 30 *minutes* you can sympathize), the rise of languages designed from the ground up to support concurrency has caught my eye.  If you&#8217;ve heard of <a href="http://erlang.org">Erlang</a> or <a href="http://www.haskell.org/">Haskell</a> you are somewhat familiar with the topic.
</p>
<p>
Then one day I ran across <a href="http://clojure.org/">Clojure</a>, a language that is a dialect of Lisp but runs on the JVM.  My, my, what in interesting combination.  I&#8217;ve talked about Clojure before, but I have not talked about the amazing person behind it, <a href="http://en.wikipedia.org/wiki/Rich_Hickey">Rich Hickey</a>.
</p>
<p>
The idea of <a href="http://createyourproglang.com/">creating your own programming language</a> is one that I find extremely intimidating, not having a formal background in computer science.  I have a vague idea of how you would do it:  write parsers for your code and then compile them into byte code that can be run by something.  Very simplistic, I know.
</p>
<p>
So Rich Hickey is a one of these programming gurus who I am sure is a super-nice guy but I would be totally intimidated to have any sort of meaningful programming-related discussion with.  First of all, he&#8217;s a Lisp hacker.  Some of my friends have described Lisp as &#8220;the cockroach of the programming world, which will be around long after the sun of other languages have dimmed&#8221; and I can&#8217;t say that I disagree much with that statement.  For someone who learned to program by teaching himself PHP, Lisp&#8217;s syntax takes a lot of getting used to.
</p>
<p>But then I think the best trick was making Clojure run on the <a href="http://en.wikipedia.org/wiki/Jvm">JVM</a>.  Why do I think this is significant?  It means that if there is a feature or a library that doesn&#8217;t exist in Clojure, you can always use a Java equivalent (if such a one exists).  In Tim Bray&#8217;s &#8220;Concur Next&#8221; series he showed an example where he used a Java library in Clojure to help him speed things up.
</p>
<p>
So not only does he have a well-designed and well-thought-out programming language, he is also great at explaining programming concepts.  Go and watch this video on the topic of <a href="http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey">basic principles like state, identity, value, time, and many others</a> in order to understand how to build concurrent and parallel systems.  Fascinating talk, and I highly recommend seeking out other talks that he&#8217;s done as well.
</p>
<p>
All this stuff is absolutely fascinating to me, because my entire programming career has been spent in the stateless environment of the web.  Oh sure, we can fake state and concurrency using sessions and cookies, but they are really just hacks.  Does a web application need to be stateful and/or concurrent?  The answer is, of course, it depends. <img src='http://www.littlehart.net/atthekeyboard/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   Online games with multiple participants definitely need to worry about sharing state across multiple clients, and any web application that is taking large amounts of data and processing it (like munging it together based on aggregate conditions) could benefit from being able to crunch the data concurrently, with all jobs reporting stuff as they go.  Any task that would benefit from being broken down into smaller tasks that can be run at once is a candidate for concurrency.
</p>
<p>
So, why does Rich Hickey make me feel stupid?  <b>Not only is he also capable of explaining the hows and whys of a concurrent programming language, he is encouraging people to think ahead to the next generation of programming problems and potential solutions to those problems.</b>.  It&#8217;s highly unlikely I will ever create a full-blown, general-purpose programming language.  But Rich Hickey&#8217;s work has gotten me thinking about programming in event-driven environments, and wondering what tasks that my current applications perform could benefit from concurrency and parallelism.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2010/03/03/people-who-make-me-feel-stupid-rich-hickey/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>People Who Make Me Feel Stupid: Antirez</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/03/02/people-who-make-me-feel-stupid-antirez/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2010/03/02/people-who-make-me-feel-stupid-antirez/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 14:00:00 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[key-value]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Redis]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=669</guid>
		<description><![CDATA[This is the second of a five-part series where I highlight some developers who are doing work or espousing practices that make me feel stupid and realize where I need to push my skills towards.  Today&#8217;s source of inspiration:  the man know by many online as Antirez, Italian software developer Salvatore Sanfilippo.
Antirez is [...]]]></description>
			<content:encoded><![CDATA[<p>This is the second of a five-part series where I highlight some developers who are doing work or espousing practices that make me feel stupid and realize where I need to push my skills towards.  Today&#8217;s source of inspiration:  the man know by many online as <a href="http://antirez.com/">Antirez</a>, Italian software developer Salvatore Sanfilippo.</p>
<p>Antirez is the driving force behind <a href="http://code.google.com/p/redis/">Redis</a>, which is described as &#8220;an advanced key-value store&#8221; where it holds your dataset in memory at all times but writes them out to disk in a couple of different ways depending on your choices (either from time-to-time or all the time to an append log, depending on what level of consistency you need from the data).
</p>
<p>When I first started watching the whole <a href="http://en.wikipedia.org/wiki/NoSQL">NoSQL</a> movement, I remember seeing Redis in there as an option there.  However, I didn&#8217;t know much about Redis until I noticed that my friend <a href="http://twitter.com/jperras">Joel Perras</a> was following this guy with an awesome mop of hair in his Twitter avatar and a cool nickname.  When I also saw he was the creator of Redis I knew this was a guy I had to follow and see what he was up to.
</p>
<p>
I won&#8217;t go into the whole rationale behind the NoSQL movement, but what makes me feel stupid is not just the *way* Antirez has chose to implement his key-value storage solution, but the man himself.  He is one really smart dude.
</p>
<p>
First of all, he might be the most prolific hacker I&#8217;ve seen out there who actually lets people know what he&#8217;s been up to.  His Twitter stream is full of comments about stuff he&#8217;s been working on in Redis, some of which I understand and some of which goes right over my head (especially the <a href="http://antirez.com/post/redis-virtual-memory-story.html">stuff about the Virtual Memory work he&#8217;s done with Redis</a> just shows me what I missed by not taking computer science courses.  Too busy teaching myself the new and shiny I guess.
</p>
<p>
Second, he spits out this volume of information in English.  Which is NOT his first language.  I couldn&#8217;t imagine translating technical terms into my second fairly proficient language (which is German, and I understand it spoken way better than I speak it, read it or write it).  I have a hard enough time understanding technical terms written in English, never mind translating them in my head from another language.
</p>
<p>
So back to Redis now.  So not only is it a high-performance key-value store, using memory (the fastest storage medium) to store your data, but it also suited for use in a master-slave replication setup (claiming very fast replication speeds, and given the torturous bench marks I have seen Antirez talk about on twitter and his blog, I believe him) but can also do something that a lot of post-relational data stores (perhaps that&#8217;s a better name than NoSQL) can&#8217;t do:  unions (am I correct in assuming that is the equivalent of JOINS from the SQL world?), set intersections, comparisons between sets, and even generating sorted results.  I could see using Redis as the data store for the web front end of the corporate fantasy draft application at work.  I&#8217;m using a lot of key-value pairs in it, so a hybrid approach would probably work the best if I were to try it.
</p>
<p>
I mean, when you read that Virtual Memory post how can you *not* feel stupid for failing to see why Redis needs such a thing:  if you are storing everything in memory (remember, disk is the new tape) then you need your use of that memory to be as advantageous as possible and not rely on the operating system to do it for you.  For Redis, you want to keep as much memory available for your data so Antirez felt that he needed to find a way to free up the memory being used by the least-frequently accessed data.  A hard problem to solve for sure, but reading about what he did is just so inspiring.  As a bonus, you also learn some computer science skills along the way.  I felt the same way when I listened to a lecture about building virtual machines for Ruby:  awed and wondering if they teach that sort of stuff in computer science courses.
</p>
<p>While Redis might not be a solution I ever use at work (I am trying to keep our stack from adding too many new components just because I feel like playing with them) it&#8217;s worth the lost hours reading Antirez&#8217; blog to understand all that goes on behind the scenes to make a cool piece of technology usable outside some very narrow scenarios.
</p>
<p>So, in the end, why did Antirez make me feel stupid?  <b>It was because he made me realize that you could take a simple idea (the key-value store) and add all sorts of very desirable features onto it without compromising it&#8217;s main goal</b>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2010/03/02/people-who-make-me-feel-stupid-antirez/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>People Who Make Me Feel Stupid: Geoffrey Grosenbach</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/03/01/people-who-make-me-feel-stupid-geoffrey-grosenbach/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2010/03/01/people-who-make-me-feel-stupid-geoffrey-grosenbach/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 14:00:02 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[Blueprint CSS]]></category>
		<category><![CDATA[HAML]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Sass]]></category>
		<category><![CDATA[Sinatra]]></category>
		<category><![CDATA[Textile]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=664</guid>
		<description><![CDATA[For this upcoming week I am going to be doing 5 blog posts about developers who have been doing work that makes me feel stupid as a developer.  The main reason for this is a week spent on introspection as to not only how I am building applications for my employer but also how [...]]]></description>
			<content:encoded><![CDATA[<p>For this upcoming week I am going to be doing 5 blog posts about developers who have been doing work that makes me feel stupid as a developer.  The main reason for this is a week spent on introspection as to not only how I am building applications for my employer but also how I build things on the side.  To be blunt, I&#8217;m not happy.  This is not to say that the work isn&#8217;t interesting (building out corporate fantasy sports draft web front-ends and also plans for our next-gen fantasy gaming platform) but rather that my method of choosing what pieces I glue together have been missing the mark.
</p>
<p>Some of this is due to my desire to always push myself to learn new things, so sometimes the joy of discovery tramples the ability to get things done as quickly as I would like.  So I&#8217;ve been looking around at how other people have been solving problems in an attempt to discover blind spots I&#8217;ve developed.  The first person I found that made me say out loud &#8220;boy, does this guy make me feel stupid&#8221; during this process is <a href="http://geoffreygrosenbach.com/">Geoffrey Grosenbach.</a>
</p>
<p>
About 5 years ago I was looking to get into the Ruby on Rails world.  I had bought the <a href="http://pragprog.com/titles/ruby/programming-ruby">Pick Axe Book</a> and the 1st edition of <a href="http://pragprog.com/titles/rails1/agile-web-development-with-rails-1st-edition">the Rails book</a>.  Through my online digging I discovered the <a href="http://podcast.rubyonrails.org/">Ruby on Rails podcast</a>, run at the time by the previously-mentioned Geoffrey Grosenbach.  It was all cool and interesting, and he seemed to have a knack for asking the right kind of questions.  Either that or he was really good at the editing. <img src='http://www.littlehart.net/atthekeyboard/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />
</p>
<p>
Alas, things didn&#8217;t work out.  I built a Rails site, but it had some problems due to my n00bishness with the framework and the language.  Let&#8217;s just say I wasn&#8217;t using Ruby best practices.  The final nail in the coffin for my Ruby aspirations was when I turned down a Rails gig to instead take a telecommuting PHP gig (life choices dictated that one) and I drifted off into other things.  But I kept an eye on what Geoffrey was doing anyway and was happy to see him find success with Peepcode along the way.
</p>
<p>
Then I came across an awesome blog post from him where he talked about <a href="http://blog.peepcode.com/tutorials/2010/about-this-blog">how he builds the Peepcode Blog</a>.  I read it and was totally blown away, and totally humbled by the simplicity of what he has done.  Rather than simply do some link bait and show you everything he used, you can go and look at it
</p>
<p>
He explained that his goal was to produce an &#8220;art blog&#8221; for Peepcode, where every blog post would have it&#8217;s own unique look to it.  In order to do this, he had to think about what goes into building something like this:</p>
<ul>
<li>A CSS grid layout system, because it&#8217;s really too hard to always come up with your own unique layouts.  A grid makes it easier to make interesting content I think.</li>
<li>A very simple application framework for spitting out static images and HTML. (This was the lightbulb-went-on thing for me, as a blog that does not have comments can be totally static)</li>
<li>A modified version of an existing lightweight blogging engine to fit his needs.</li>
<li>Storing blog content in flatfiles on the system.  Again, without dynamic content why bother with the overhead of storing posts in a database (says the guy using WordPress, one of the favourite targets of criticism by PHP developers who like their code clean and modular)</li>
<li>The use of a markup language to reduce the actual HTML he had to write</li>
<li>The use of a CSS framework to again reduce the need to write actual CSS</li>
<li>A sprinkling of Javascript to add unique features to each page</li>
</ul>
<p>I&#8217;ve read that blog post at least a dozen times now, and still marvel at how frickin&#8217; obvious it was to do things the way he did.  It&#8217;s also obvious that he put a lot of thought into what he needed and the best way to couple things together to make it happen.</p>
<p>
Compare his methods to my current set of decisions as to the various tools to build a web front end for a corporate draft</p>
<ul>
<li>A glue framework with lots of components that can be legitimately accused of starting to become bloated</li>
<li>Use of an ORM to spare me from writing SQL to pull in dynamic sports data</li>
<li>Table-driven HTML layouts from the previous generation of the application</li>
</ul>
<p>When you start to factor in the time to actually learn not only the framework itself (and also heavily relying on a particular module of it to give me the MVC features I wanted) but the ORM itself, I wonder if it was the right decision.
</p>
<p>
Because if I were to break it down in a similar fashion to how the Peepcode blog was built, I&#8217;d say I need the following</p>
<ul>
<li>lightweight scripting language front-end (in this case PHP because that&#8217;s what all our other client-facing applications use)</li>
<li>a component to handle dynamic routing of requests, although I could really use web server rewrite rules instead of making the front-end code figure it out.  My mod_rewrite skills have gotten a little better in the last year or so.</li>
<li>An RDBMs because the source data is in a database already, and so few NoSQL solutions allow you to do the kind of grouping and aggregate math functions I need to do that MySQL can handle for me.</li>
<li>An authentication component.  I&#8217;ve written enough of these to know it&#8217;s easier to use someone else&#8217;s that just works</li>
<li>An access control component.  I&#8217;ve written enough of these to know it&#8217;s easier to use someone else&#8217;s that just works too.</li>
<li>Grid-based CSS framework for layouts so we can use as few tables as possible.</li>
<li>An easy-to-use Javascript library to take care of everything else that I cannot do in the scripting language or via CSS.</li>
</ul>
<p>
Man, I&#8217;m starting to think that <a href="http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html">Rasmus was right</a> with apologies to my friend <a href="http://twitter.com/chiggsy">Kevin Beckford</a>.  Kevin is of the opinion that main reason to use a framework to build something is because unless you will be the only one ever to write and maintain that application, the rules and structure that a framework gives are essential to help your fellow coders stay on track.  It&#8217;s like having a common language that you both speak, and easy access to a dictionary (the documentation for that framework).
</p>
<p>
In my case, I am using PHP + Zend_Framework + Zend_Application + Zend_Auth + Zend_Acl + Doctrine + MySQL (plus Python on the server to do some data munging)  to build this thing out.  Luckily, no Javascript needed at this point.  So what could I strip out to build it the way I put it above?  We could end up with PHP + Apache rewrite rules + Zend_Auth + Zend_Acl + MySQL + Python, with Blueprint CSS thrown in to help me with the layouts.  Not a *whole* lot of difference from before.
</p>
<p>
But of course, I was able to quickly build out admin functionality for the front end due to the ability to map out relationships between tables and having Doctrine pull in all that data and return it to me in a ready-to-go package for easy display.  Also, to be realistic, we are too far into the project to rip all that stuff out and quickly refactor it.  I mean, how do I justify stripping out Doctrine and writing all the &#8220;query, process and stick into variables&#8221; code now?  It&#8217;s a delicate dance, and it&#8217;s obvious those decisions need to be made before you start, not when you&#8217;re experiencing some mild <a href="http://en.wikipedia.org/wiki/Buyer%27s_remorse">Buyer&#8217;s Remorse</a>.
</p>
<p>So, in the end, why did Geoffrey Grosenbach make me feel stupid?  <b>It was because he made me realized that I have a tendency to what to overengineer things a bit, wrapping them in framework solutions when perhaps the more direct route is to couple existing modules together to have a more flexible solution</b>.
</p>
<p>
But I have at least considered that the tools I was using were going to make it easier to build out the behind-the-scenes stuff.  Sure, I could write all the SQL code myself (I&#8217;ve finally understood the power of joins), but once I&#8217;ve learned how Doctrine does things it becomes super simple to build on the existing work.
</p>
<p>
Look at the Peepcode blog setup shows that he was using a bunch of tools already in widespread use in the Ruby and Rails communities.  There are not many equivalences for that stuff in the PHP world (HAML and SASS only have incomplete implementations for use with PHP as far as I can tell) but the approach he used is the one to really think about.  I mean, what would this blog look like if I decided to go the minimalist route, but with tools that I am more comfortable with?  Could I do it with <a href="http://werkzeug.pocoo.org/">Werkzeug</a> + a simple blog engine + <a href="http://en.wikipedia.org/wiki/Textile_(markup_language)">Textile</a> + <a href="http://www.blueprintcss.org/">Blueprint CSS</a> + jQuery?  I have no spare time as it is, what would this type of project do to me?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2010/03/01/people-who-make-me-feel-stupid-geoffrey-grosenbach/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Where In Chris Reads The Documentation&#8230;and Does Not Find The Answer</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/02/19/where-in-chris-reads-the-documentation-and-does-not-find-the-answer/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2010/02/19/where-in-chris-reads-the-documentation-and-does-not-find-the-answer/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 21:33:23 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=662</guid>
		<description><![CDATA[If you follow me on Twitter you&#8217;ve seen me pissing and moaning about not being able to figure stuff out as I build out my first Zend Framework project in a LONG time.  3 years to be exact.  I had two things that I wanted to add to the project:  (1) a [...]]]></description>
			<content:encoded><![CDATA[<p>If you follow me on Twitter you&#8217;ve seen me pissing and moaning about not being able to figure stuff out as I build out my first <a href="http://framework.zend.com">Zend Framework</a> project in a LONG time.  3 years to be exact.  I had two things that I wanted to add to the project:  (1) a new custom controller to base some other controllers off of and (2) create custom routes for it.  Sounds simple, right?
</p>
<p>
I have stared into the belly of the beast that is the Zend Framework documentation and have discovered the following truth:  there always seems to be two ways to do something.  For someone just starting out learning a framework (never mind their actual level of experience with PHP itself) this is not a good thing.  For example, let&#8217;s look at creating a new base controller to extend controllers off of.  Via twitter I found the following ways:</p>
<ul>
<li>no, don&#8217;t do that, use custom action helpers</li>
<li>sure, just put it somewhere and use autoloading to find it</li>
</ul>
<p>
So I proceeded to start digging around and figure things out.  Hrm, an action helper is not what I need, so let&#8217;s create that new base controller.  Oh, you mean you can have more than one way to lay out your project, even if you are using Zend_Application?  How come it&#8217;s not finding the new controller even though I put it in a common place.  Why won&#8217;t this work?!?  DAMNIT, I AM GOING TO QUIT PROGRAMMING AND RUN A DADDY DAY CARE OUT OF MY HOME.
</p>
<p>Fortunately the custom routing thing was easier to figure out.   Hey, here&#8217;s an example of adding code to your bootstrap.  Oh wait, I&#8217;m using Zend_Application so things are different.  WTF, I am overriding my existing routes and everything is broken?!?  You can put this stuff in XML?!?!  But I am using the .ini format&#8230;.  Nice, <a href="http://weierophinney.net/matthew/">MWOP</a> pointed me in the right direction.  Good thing he&#8217;s on twitter.
</p>
<p>
Look, I&#8217;ve talked about this before.  It&#8217;s awesome to have lots of documentation.  The Zend Framework documentation is awesome&#8230;but seems to only have 80% of the solutions I was looking for.  Digging around using Google just seemed to point me at the same 80%-complete documentation.
</p>
<p>
Writing documentation is a thankless task, so do not interpret my comments as a slam against those who are contributing.  I work best when I see FULL examples on how to do something, and then I can &#8220;extend and embrace&#8221; that to produce the customized solutions I always end up needing.  My complaints are solely my own, which is why I usually blog the solutions when I come up them.  I certainly cannot be the only one having problems sifting through the documentation.
</p>
<p>
As someone who had invested a lot of time in another framework, I am painfully aware of how much you take for granted when using a familiar tool, and then try to help people solve a problem.  My own experiences have ranged from &#8220;you are most definitely doing it wrong&#8221; to &#8220;I&#8217;ve never done it that way, and I can see how that will work&#8221;.
</p>
<p>
Special thanks to @weierophinney, @elazar and @andriesss for their actual help and offers of help as I stumble around using Zend Framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2010/02/19/where-in-chris-reads-the-documentation-and-does-not-find-the-answer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sorting Relationship Results In Doctrine 1.2</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/02/04/sorting-relationship-results-in-doctrine-1-2-2/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2010/02/04/sorting-relationship-results-in-doctrine-1-2-2/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 17:57:24 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[Doctrine]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[table relationships]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=659</guid>
		<description><![CDATA[
I've been building an admin panel for a work project dealing with fantasy sports, and one of the failings of the old version of the overall application was that, well, sometimes it didn't retain the desired display order of players grouped by position.  Sometimes it worked, sometimes it didn't.  A classic case of [...]]]></description>
			<content:encoded><![CDATA[<p>
I've been building an admin panel for a work project dealing with fantasy sports, and one of the failings of the old version of the overall application was that, well, sometimes it didn't retain the desired display order of players grouped by position.  Sometimes it worked, sometimes it didn't.  A classic case of "software working by accident" maybe?  So I've set out to fix that part of it.
</p>
<p>
I've been using <a href="http://www.doctrine-project.org">Doctrine</a> 1.2 for the project (integrated with <a href="http://framework.zend.com">Zend Framework</a>), and I found it quite easy to setup the relationships I needed between my models.  Oh, except for finding out that I really needed a field called 'id' in one table in order to make a relationship work properly.  Sometimes convention triumphs over configuration. <img src='http://www.littlehart.net/atthekeyboard/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
So I thought to myself "I wonder if I can configure things so that when we're pulling in the related results, it is sorted?"
</p>
<p>
So I started digging around via search engine.  Took me about an hour to find the solution.  First, it took me half the time to dive deep enough to find out WHERE I can define the default sort order.  Surprisingly, it was in an area that made total sense but I could not find before.  Weird.  Probably due to me not fulling understanding the API.
</p>
<div class="igBar"><span id="lphp-2"><a href="#" onclick="javascript:showPlainTxt('php-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-2">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> Team extends Doctrine_Record </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> setUp<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">hasMany</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Player as Players'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'local'</span> =&gt; <span style="color:#FF0000;">'team_id'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'foreign'</span> =&gt; <span style="color:#FF0000;">'player_id'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'refClass'</span> =&gt; <span style="color:#FF0000;">'PlayersTeams'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'orderBy'</span> =&gt; <span style="color:#FF0000;">'FIELD(position, &quot;C&quot;,&quot;1B&quot;, &quot;2B&quot; ,&quot;3B&quot;, &quot;SS&quot;, &quot;OF&quot;, &quot;P&quot;)'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>
Oh, what's all that other stuff?  That's what took the other half of the hour to figure out.  See, I couldn't use any sort of natural sorting order.  I had a specific order that they needed to be displayed in.  As usual <a href="http://stackoverflow.com/questions/134379/returning-query-results-in-predefined-order">StackOverflow came to my rescue</a>.  I'm pretty sure that what I am doing is MySQL-specific but I imagine you can figure it out for other RDBMS'.
</p>
<p>
So now when I pull in info about a Team, I get the associated Player records sorted to my heart's desire.  Awesome.  This does raise a question:  how would you accomplish this sort of trick if you were using a non-relational database like <a href="http://couchdb.apache.org">CouchDB</a>.  Research for another day I guess.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2010/02/04/sorting-relationship-results-in-doctrine-1-2-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Creating Usable Forms With Zend Framework</title>
		<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>
		<comments>http://www.littlehart.net/atthekeyboard/2010/01/27/creating-usable-forms-with-zend-framework/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 00:06:56 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[decorators]]></category>
		<category><![CDATA[reusable forms]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Form]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=653</guid>
		<description><![CDATA[Note: These examples are using Zend Framework 1.9.5, with comes with Zend Server Community Edition 4.0.6 for OS-X
As I begin working on the admin area for a work application being built with Zend Framework, I've been spending a lot of time starting and stopping on it.  Why?  Chalk it up to the extensibility [...]]]></description>
			<content:encoded><![CDATA[<p><i>Note: These examples are using Zend Framework 1.9.5, with comes with Zend Server Community Edition 4.0.6 for OS-X</i></p>
<p>As I begin working on the admin area for a work application being built with <a href="http://framework.zend.com">Zend Framework</a>, I've been spending a lot of time starting and stopping on it.  Why?  Chalk it up to the extensibility of Zend Framework, who have clearly taken the "configuration" side of the "configuration vs. convention" philosophy when it comes to frameworks.  Before you get all worked up, remember that (a) I last used Zend Framework 3 years ago and (b) I got very used to relying on framework conventions to help me speed things up, a tactic used with great success in building <a href="http://cakephp.org">CakePHP</a> and <a href="http://codeigniter.com">CodeIgniter</a> applications.  Alas, those days are behind me and I am getting schooled in the wonders of "figuring everything out" and "object chaining is cool" and "why are there always more than one way to do something with this framework?!?".
</p>
<p>
So one of my first tasks is to create a form to allow people to create new leagues for a fantasy sports league.  Need a very simple form with three things in it: league name, sport and scoring period (which is how often we need to compile standings).  Sounds easy right?
</p>
<p>
After searching around online for some examples of building simple forms, I was dismayed to discover there were two different ways of building the form.  I could (a) do it the long way and create specific instances of the form elements using Zend_Form_Element_X or (b) do it the short way and add them to the form by use of <a href="http://framework.zend.com/apidoc/1.9/Zend_Form/Zend_Form.html#addElement">Zend_Form::addElement()</a> and pass it the type of form element I want via an array.  For reasons I cannot explain initially, I decided to do things the long way.  Later on, I found out that doing it this way saved me from rewriting.
</p>
<p>
So, the approach I decided to use was to create a separate file that contains the form I want to use.  Why? Because I wanted to reuse this form for both "add a new league" functionality and "edit an existing league" functionality.  After figuring out that I needed to create a Bootstrap file for the module that the form was in (otherwise auto loading wouldn't work) here's what I cranked out:</p>
<div class="igBar"><span id="lphp-9"><a href="#" onclick="javascript:showPlainTxt('php-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-9">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> Admin_Form_League extends Zend_Form</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> __construct<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$options</span> = <span style="color:#000000; font-weight:bold;">null</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; parent::__construct<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">setAction</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'action'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>-&gt;<span style="color:#006600;">setMethod</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'post'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$name</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Form_Element_Text<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'name'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'required'</span> =&gt; <span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sport</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Form_Element_Select<span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'sport'</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'required'</span> =&gt; <span style="color:#000000; font-weight:bold;">true</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'multiOptions'</span> =&gt; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'baseball'</span> =&gt; <span style="color:#FF0000;">'Baseball'</span>, <span style="color:#FF0000;">'football'</span> =&gt; <span style="color:#FF0000;">'Football'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$scoringPeriod</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Form_Element_Select<span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'scoring_period'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'required'</span> =&gt; <span style="color:#000000; font-weight:bold;">true</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'multiOptions'</span> =&gt; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'daily'</span> =&gt; <span style="color:#FF0000;">'Daily'</span>, <span style="color:#FF0000;">'weekly'</span> =&gt; <span style="color:#FF0000;">'Weekly'</span>, <span style="color:#FF0000;">'monthly'</span> =&gt; <span style="color:#FF0000;">'Monthly'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$submit</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Form_Element_Submit<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'submit'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'label'</span> =&gt; <span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'submitLabel'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'leagueId'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$leagueId</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Form_Element_Hidden<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'id'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'value'</span> =&gt; <span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'leagueId'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">addElement</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$leagueId</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">addElements</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$name</span>, <span style="color:#0000FF;">$sport</span>, <span style="color:#0000FF;">$scoringPeriod</span>, <span style="color:#0000FF;">$submit</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Perhaps you've noticed something different about this example compared to others you might have seen elsewhere?  Okay, I won't keep you in suspense about it.  I'm using the $options parameter when creating an instantiation of this particular form to pass some dynamic information.  Without this, it would be very difficult to reuse this form.  In this case, I pass in up to three different parameters:  the target for the form, the label I want on the submit button and (in the case where we're editing an existing record) the primary key of that league in the database.
</p>
<p>
So, then the next step is to tell my controller I want to use that form.  Ignore the database related stuff as I'm using <a href="http://www.doctrine-project.org/">Doctrine</a> and my use of that probably deserves it's own blog post down the line.</p>
<div class="igBar"><span id="lphp-10"><a href="#" onclick="javascript:showPlainTxt('php-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-10">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> Admin_IndexController extends Zend_Controller_Action</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; protected <span style="color:#0000FF;">$_flashMessenger</span> = <span style="color:#000000; font-weight:bold;">null</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> init<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_flashMessenger = <span style="color:#0000FF;">$this</span>-&gt;_helper-&gt;<span style="color:#006600;">getHelper</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'FlashMessenger'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">initView</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> indexAction<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$leagues</span> = Doctrine::<span style="color:#006600;">getTable</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Leagues'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$form</span> = <span style="color:#000000; font-weight:bold;">new</span> Admin_Form_League<span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'action'</span> =&gt; <span style="color:#FF0000;">'/admin/index'</span>, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'submitLabel'</span> =&gt; <span style="color:#FF0000;">'Add New League'</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;_request-&gt;<span style="color:#006600;">getPost</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$formData</span> = <span style="color:#0000FF;">$this</span>-&gt;_request-&gt;<span style="color:#006600;">getPost</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">isValid</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$formData</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$newLeague</span> = <span style="color:#000000; font-weight:bold;">new</span> Leagues<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$newLeague</span>-&gt;<span style="color:#006600;">fromArray</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">getValues</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$newLeague</span>-&gt;<span style="color:#006600;">save</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">populate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$formData</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">view</span>-&gt;<span style="color:#006600;">leagues</span> = <span style="color:#0000FF;">$leagues</span>-&gt;<span style="color:#006600;">findAll</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>-&gt;<span style="color:#006600;">toArray</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">view</span>-&gt;<span style="color:#006600;">messages</span> = <span style="color:#0000FF;">$this</span>-&gt;_flashMessenger-&gt;<span style="color:#006600;">getMessages</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">view</span>-&gt;<span style="color:#006600;">form</span> = <span style="color:#0000FF;">$form</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
</p>
<p>Nice and simple, and effective.  I also have another action that is for the editing or deleting an existing league.  Here's the controller for that</p>
<div class="igBar"><span id="lphp-11"><a href="#" onclick="javascript:showPlainTxt('php-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-11">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> Admin_LeaguesController extends Zend_Controller_Action</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> init<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_flashMessenger = <span style="color:#0000FF;">$this</span>-&gt;_helper-&gt;<span style="color:#006600;">getHelper</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'FlashMessenger'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">initView</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> editAction<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$leagueId</span> = <span style="color:#0000FF;">$this</span>-&gt;_getParam<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'id'</span>, <span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$leagues</span> = Doctrine::<span style="color:#006600;">getTable</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Leagues'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;_request-&gt;<span style="color:#006600;">getPost</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$formData</span> = <span style="color:#0000FF;">$this</span>-&gt;_request-&gt;<span style="color:#006600;">getPost</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$form</span> = <span style="color:#000000; font-weight:bold;">new</span> Admin_Form_League<span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'action'</span> =&gt; <span style="color:#FF0000;">'/admin/leagues/edit'</span>, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'submitLabel'</span> =&gt; <span style="color:#FF0000;">'Update League'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'leagueId'</span> =&gt; <span style="color:#0000FF;">$formData</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">isValid</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$formData</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$updateLeague</span> = <span style="color:#0000FF;">$leagues</span>-&gt;<span style="color:#006600;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$formData</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$updateLeague</span>-&gt;<span style="color:#006600;">name</span> = <span style="color:#0000FF;">$formData</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'name'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$updateLeague</span>-&gt;<span style="color:#006600;">sport</span> = <span style="color:#0000FF;">$formData</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'sport'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$updateLeague</span>-&gt;<span style="color:#006600;">scoring_period</span> = <span style="color:#0000FF;">$formData</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'scoring_period'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$updateLeague</span>-&gt;<span style="color:#006600;">save</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_flashMessenger-&gt;<span style="color:#006600;">addMessage</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Updated league'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_redirect<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/admin'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/exit"><span style="color:#000066;">exit</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">populate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$formData</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$leagueId</span> = <span style="color:#0000FF;">$this</span>-&gt;_getParam<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'id'</span>, <span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$leagueId</span> == <span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_redirect<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/admin'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/exit"><span style="color:#000066;">exit</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$form</span> = <span style="color:#000000; font-weight:bold;">new</span> Admin_Form_League<span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'action'</span> =&gt; <span style="color:#FF0000;">'/admin/leagues/edit'</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'submitLabel'</span> =&gt; <span style="color:#FF0000;">'Update League'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'leagueId'</span> =&gt; <span style="color:#0000FF;">$leagueId</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$results</span> = <span style="color:#0000FF;">$leagues</span>-&gt;<span style="color:#006600;">findById</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$leagueId</span><span style="color:#006600; font-weight:bold;">&#41;</span>-&gt;<span style="color:#006600;">toArray</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$formData</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'name'</span> =&gt; <span style="color:#0000FF;">$results</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'name'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'sport'</span> =&gt; <span style="color:#0000FF;">$results</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'sport'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'scoring_period'</span> =&gt; <span style="color:#0000FF;">$results</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'scoring_period'</span><span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">populate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$formData</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">view</span>-&gt;<span style="color:#006600;">form</span> = <span style="color:#0000FF;">$form</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> deleteAction<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$leagueId</span> = <span style="color:#0000FF;">$this</span>-&gt;_getParam<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'id'</span>, <span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$leagueId</span> == <span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_redirect<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/admin'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/exit"><span style="color:#000066;">exit</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$leagues</span> = Doctrine::<span style="color:#006600;">getTable</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Leagues'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$deleteLeague</span> = <span style="color:#0000FF;">$leagues</span>-&gt;<span style="color:#006600;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$leagueId</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$deleteLeague</span>-&gt;<span style="color:#006600;">delete</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$deleteMessage</span> = <span style="color:#FF0000;">'Deleted league'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$deleteMessage</span> = <span style="color:#FF0000;">'Unable to delete league'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_flashMessenger-&gt;<span style="color:#006600;">addMessage</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$deleteMessage</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_redirect<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/admin'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/exit"><span style="color:#000066;">exit</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
</p>
<p>Nothing too earth-shattering I would think.  Armed with this, I can now display my form in two different places:</p>
<div class="igBar"><span id="lphp-12"><a href="#" onclick="javascript:showPlainTxt('php-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-12">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;h1&gt;Admin home&lt;/h1&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;h2&gt;Leagues&lt;/h2&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/count"><span style="color:#000066;">count</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">messages</span><span style="color:#006600; font-weight:bold;">&#41;</span>&gt; <span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> : <span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;ul&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <span style="color:#616100;">foreach</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">messages</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$message</span><span style="color:#006600; font-weight:bold;">&#41;</span> : <span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;li&gt;&lt;?php <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$message</span> ?&gt;&lt;/li&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> endforeach; <span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/ul&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <span style="color:#616100;">endif</span>; <span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;table border=<span style="color:#CC66CC;color:#800000;">1</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;tr&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;League Name&lt;/th&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;Sport&lt;/th&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;Scoring Period&lt;/th&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/tr&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <span style="color:#616100;">foreach</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">leagues</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$league</span><span style="color:#006600; font-weight:bold;">&#41;</span> : <span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;tr&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;?php <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$league</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'name'</span><span style="color:#006600; font-weight:bold;">&#93;</span> ?&gt;&lt;/td&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;?php <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$league</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'sport'</span><span style="color:#006600; font-weight:bold;">&#93;</span> ?&gt;&lt;/td&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;?php <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$league</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'scoring_period'</span><span style="color:#006600; font-weight:bold;">&#93;</span> ?&gt;&lt;/td&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;a href=<span style="color:#FF0000;">"/admin/leagues/edit/id/&lt;?php echo $league['id'] ?&gt;"</span>&gt;Edit&lt;/a&gt; &lt;a href=<span style="color:#FF0000;">"/admin/leagues/delete/id/&lt;?php echo $league['id'] ?&gt;"</span> onClick=<span style="color:#FF0000;">"return confirm('Are you sure you want to delete this league?');"</span>&gt;Delete&lt;/a&gt;&lt;/td&gt;&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/tr&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> endforeach; <span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;tr&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">form</span> <span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/tr&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/table&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lphp-13"><a href="#" onclick="javascript:showPlainTxt('php-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-13">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;h1&gt;Edit league&lt;/h1&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/p&gt;&lt;p&gt;Use the form below to edit an existing league&lt;/p&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;table border=<span style="color:#CC66CC;color:#800000;">1</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;tr&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;League Name&lt;/th&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;Sport&lt;/th&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;Scoring Period&lt;/th&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/tr&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;tr&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">form</span> <span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/tr&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/table&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>So I do that, and load up the form and...what the?  Damn, the default decorator for these elements is ugly.  I want my form fields to line up nicely inside my table (shut up, I know I should use CSS but this is an admin panel and I am in a hurry) so after finding <a href="http://devzone.zend.com/article/3450">this article by Zend Framework architect MWOP</a> I figured out how to create the exact decorator I wanted.  Here's the final version of my reusable form.</p>
<div class="igBar"><span id="lphp-14"><a href="#" onclick="javascript:showPlainTxt('php-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-14">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> Admin_Form_League extends Zend_Form</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> __construct<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$options</span> = <span style="color:#000000; font-weight:bold;">null</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; parent::__construct<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">setAction</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'action'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>-&gt;<span style="color:#006600;">setMethod</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'post'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$decoratorOptions</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'ViewHelper'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'Errors'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'data'</span> =&gt; <span style="color:#FF0000;">'HtmlTag'</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'tag'</span> =&gt; <span style="color:#FF0000;">'td'</span>, <span style="color:#FF0000;">'class'</span> =&gt; <span style="color:#FF0000;">'element'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$name</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Form_Element_Text<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'name'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'required'</span> =&gt; <span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$name</span>-&gt;<span style="color:#006600;">setDecorators</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$decoratorOptions</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sport</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Form_Element_Select<span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'sport'</span>, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'required'</span> =&gt; <span style="color:#000000; font-weight:bold;">true</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'multiOptions'</span> =&gt; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'baseball'</span> =&gt; <span style="color:#FF0000;">'Baseball'</span>, <span style="color:#FF0000;">'football'</span> =&gt; <span style="color:#FF0000;">'Football'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sport</span>-&gt;<span style="color:#006600;">setDecorators</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$decoratorOptions</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$scoringPeriod</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Form_Element_Select<span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'scoring_period'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'required'</span> =&gt; <span style="color:#000000; font-weight:bold;">true</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'multiOptions'</span> =&gt; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'daily'</span> =&gt; <span style="color:#FF0000;">'Daily'</span>, <span style="color:#FF0000;">'weekly'</span> =&gt; <span style="color:#FF0000;">'Weekly'</span>, <span style="color:#FF0000;">'monthly'</span> =&gt; <span style="color:#FF0000;">'Monthly'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$scoringPeriod</span>-&gt;<span style="color:#006600;">setDecorators</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$decoratorOptions</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$submit</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Form_Element_Submit<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'submit'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'label'</span> =&gt; <span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'submitLabel'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$submit</span>-&gt;<span style="color:#006600;">setDecorators</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$decoratorOptions</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'leagueId'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$leagueId</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Form_Element_Hidden<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'id'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'value'</span> =&gt; <span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'leagueId'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">addElement</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$leagueId</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">addElements</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$name</span>, <span style="color:#0000FF;">$sport</span>, <span style="color:#0000FF;">$scoringPeriod</span>, <span style="color:#0000FF;">$submit</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
</p>
<p>
I'm pretty sure that if I dig around some more, I can find info on how to automatically apply that decorator to ALL my form elements if I needed that.  Maybe in the next revision.  Hope you find this example helps you to create your own reusable forms and to tweak the decorators yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2010/01/27/creating-usable-forms-with-zend-framework/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->