PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Create a form object

Creating a form object is very simple: simply instantiate Zend_Form:

<?php
$form 
= new Zend_Form;

For advanced use cases, you may want to create a Zend_Form subclass, but for simple forms, you can create a form programmatically using a Zend_Form object.

If you wish to specify the form action and method (always good ideas), you can do so with the setAction() and setMethod() accessors:

<?php
$form
->setAction('/resource/process')
     ->
setMethod('post');

The above code sets the form action to the partial URL "/resource/process" and the form method to HTTP POST. This will be reflected during final rendering.

You can set additional HTML attributes for the <form> tag by using the setAttrib() or setAttribs() methods. For instance, if you wish to set the id, set the "id" attribute:

<?php
$form
->setAttrib('id''login');

Zend Framework