我创建登录表单并添加 UserController->loginAction:
public function loginAction() {
$form = new Application_Form_Login();
$this->view->loginForm = $form;
}
如何在 layouts/scripts/header.phtml 中添加我的表单,因为我尝试了这个,但不起作用:
<?php echo $this->loginForm ?>
如果我在views/scripts/user/login.phtml 中回显表单,我会看到登录表单。
那是我的登录表单:
class Application_Form_Login extends Zend_Form {
public function init() {
$this->setDecorators(array('FormElements', 'Form'))
->setAction("/user/login/");
$username = new Zend_Form_Element_Text(array('name' => 'username', 'class' => 'input-text'));
$username->setRequired(true)
->setDecorators(array('ViewHelper',));
$this->addElements(array($username));
}
}