Quicker and cleaner Form using Zend Form

Written on February 13, 2008 | by vinu |

Usually handing forms involves coding the form in HTML and performing client and server side validation, which usually makes the code for complex forms quite unwieldy. Zend_Form which is available in Zend Framework version 1.5 aims at simplifying this process.

You can now create and add methods for validating form fields completely in Zend_Form. Here’s an example from an article at Zend Developer Zone:

$form = new Zend_Form;
$form->setAction('/resource/process')
    ->setMethod('post')
    ->setAttrib('id', 'login');
$username = new Zend_Form_Element_Text('username');
$username->addValidator('alnum')
    ->addValidator('regex', false, array('/^[a-z]/i'))
    ->setRequired(true)
    ->addFilter('StringToLower');
$form->addElement($username);
$password = new Zend_Form_Element_Password('password');
$password->addValidator('stringLength', false, array(6))
    ->setRequired(true)
$form->addElement($password);
$form->addElement(new Zend_Form_Element_Submit());

To learn more on this head over to the Zend_Form Quick start guide at : http://framework.zend.com/manual/en/zend.form.quickstart.html or an article by Cal Evans at Zend Developer Zone: Lifting the Skirt on Zend Framework 1.5 - Zend_Form

Bookmark and share: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • bodytext
  • StumbleUpon
  • BlinkList
  • blogmarks
  • Furl
  • Slashdot
  • Spurl
  • Technorati
  • YahooMyWeb
  • description
  • e-mail
  • Facebook
  • Google
  • IndianPad
  • Live
  • Ma.gnolia
  • NewsVine
  • Reddit
  • TwitThis
  1. 2 Responses to “Quicker and cleaner Form using Zend Form”

  2. By vinu on Feb 13, 2008 | Reply

    A few more advanced form techniques using Zend Framework are available at: http://gourl.in/0j

  1. 1 Trackback(s)

  2. Feb 13, 2008: PHPDeveloper.org

Post a Comment

About Me

Here's my blog on stuff I keep finding on the Web. More

Want to subscribe?

 Subscribe in a reader Or, subscribe via email:
Enter your email address:  
On the Go? Get this on your Widsets: Add to my Widsets
Find entries :