News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Chris Hartjes' Blog:
Creating Usable Forms With Zend Framework
January 28, 2010 @ 10:48:16

Chris Hartjes has a new post to his blog today looking at how to make forms in a Zend Framework application in a bit more reusable fashion.

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 Zend_Form::addElement() 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.

He includes the code for his sample form that lives in a file outside the controller so he could use it for both the "add" and "edit" actions. He shows how to plug that into the controllers, the views to show the end result and a few decorators to get rid of the default form formatting and customize it how he needed.

0 comments voice your opinion now!
zendframework form zendform reusable tutorial


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Free Zend Framework-based code generator from UML2 models

Tiffany Brown's Blog: PHP quickie: is_numeric() versus ctype_digit()

Zend Developer Zone: Using Zend_Tool to start up your ZF Project

Brandon Savage's Blog: Avoiding Notices: When to Use isset() and empty()

Zend Developer Zone: Using Zend_Feed to Merge Multiple RSS Feeds


Community Events





Don't see your event here?
Let us know!


series conference api voicesoftheelephpant community deployment symfony zendserver introduction release threedevsandamaybe framework language tips code list laravel podcast bugfix interview

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework