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