Return to Snippet

Revision: 38072
at December 24, 2010 04:53 by ischenkodv


Initial Code
public function loginAction()
{
    $form = new Application_Form_Login();
    if ($this->getRequest()->isPost()){
        if ($form->isValid($this->getRequest()->getPost())){
            $username = $form->getValue('username');
            $userpass = $form->getValue('userpass');
            $adapter = new Application_Model_AuthAdapter($username, $userpass);
            $result = $this->_auth->authenticate($adapter);
            if ($result->isValid()){
                // Success.
                // Redirect...
            } else {
                $form->setErrors(array('Invalid user/pass'));
                $form->addDecorator('Errors', array('placement' => 'prepend'));
            }
        } else {
            $form->setErrors(array('Please note the errors below'));
            $form->addDecorator('Errors', array('placement' => 'prepend'));
        }
    }
    $this->view->form = $form;
}

Initial URL

                                

Initial Description

                                

Initial Title
Displaying errors in Zend_Form

Initial Tags
form, php

Initial Language
PHP