我正在使用zend框架,並試圖使用zend窗體,MVC和OOP輸出一個簡單的登錄窗體。窗體不渲染
我的代碼是下面: 的控制器 IndexController.php
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$this->view->loginForm = $this->getLoginForm();
}
public function getLoginForm()
{
$form = new Application_Form_Login;
return $form;
}
}
這是以下形式: 的login.php
class Application_Form_Login extends Zend_Form
{
public function init()
{
$form = new Zend_Form;
$username = new Zend_Form_Element_Text('username');
$username
->setLabel('Username')
->setRequired(true)
;
$password = new Zend_Form_Element_Password('password');
$password
->setLabel('Password')
->setRequired(true)
;
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Login');
$form->addElements(array($username, $password, $submit));
}
}
和視圖: index.phtml
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
<div id="header">
<div id="logo">
<img src="../application/images/logo.png" alt="logo">
</div>
</div>
<div id="wrapper">
<?php echo $this->loginForm; ?>
</div>
</body>
</html>
我是新來的Zend Framework,MVC和OOP,所以在這下面的在線諮詢這是我最好的嘗試,教程等
我會upvote這2次,如果我可以 – Adi 2012-07-10 18:29:19