Computing Magazine

Add Form with Zend Framework

Posted on the 17 October 2012 by Akahgy

Description:

Add a working form in Zend view with method, elements and action.

Solution:

Adding a form with Zend Framework is pretty straight forward. Zend has all the methods for creating a form and transfering it in the view element.

$loginForm
  ->setMethod(‘post’)
  ->setAction(‘/customer/login’)
  ->addElement(‘text’, ‘user’, array(‘label’ => ‘Username:’))
  ->addElement(‘text’, ‘password’, array(‘label’ => ‘Password:’))
  ->addElement(‘submit’, ‘Login’);
$this->view->form = $loginForm;

The form variable takes as parameters the type of method (get or post), the elements defined by the name and label and the action triggered by the submit button.


Tagged: form, login, zend Add form with Zend Framework

Back to Featured Articles on Logo Paperblog