Friday, July 8, 2011

$form->getValues

Comments on "Easy PHP Websites With The Zend Framework (2011)" by Jason Gilmore.

If you have trouble with the code presented on page 67 in Ch. 5, try testing for form validity before using getValue():

public function loginAction()
{
$form = new Application_Model_FormLogin();

if ($this->getRequest()->isPost()) {
if ($form->isValid($this->getRequest()->getPost())) {
$values = $form->getValues();
}
$email = $form->getValue('email');
$pswd = $form->getValue('pswd');

echo "<p>Your e-mail is {$email}, and password is {$pswd}</p>";

}

$this->view->form = $form;
}
}

Sorry for the crappy formatting, but it is blogger!

0 comments: