我正在使用 Zend Framework 开发一个小型 php 应用程序。我使用创建了一个表单,Zend_Form
但是当我尝试在浏览器中显示它时,它无法正常工作。
这是我的表单类:
class IndexForm extends Zend_Form {
public function init(){
$this->setAction('main/main');
$this->setMethod('post');
$username = $this->addElement('text','uname',array('filters'=>array('StringTrim','StringToLower'),
'validators'=>array('Alpha',
array('StringLength',false,array(3,20)),
),
'required'=>true,
'label'=>'User Name:'));
$password = $this->addElement('password','pwd',array('filters'=>array('StringTrim'),
'validtors'=>array('Alnum',
array('StringLength',false,array(6,20)),),
'required'=>true,
'label'=>'Password:'
));
$login = $this->addElement('submit', 'login', array(
'required' => false,
'ignore' => true,
'label' => 'Login',
));
}
}
?>
这是我的 IndexController.php
<?php
class IndexController extends Zend_Controller_Action {
public function init() {
/*
* Initialize action controller here
*/
}
public function indexAction() {
include APPLICATION_PATH.'/models/Forms/IndexForm.php';
$form = new IndexForm();
$this->view->form = $form;
}
}
这是我index.phtml
的,我需要在其中显示表单。
<html>
<style>
</style>
<body><br>
<img alt="" src="http://localhost/Accounts/application/views/scripts/images/logo.png" width=200px height=80px><!-- see whether you can get the host name dynamically -->
<div id="text" >
<h1>Welcome</h1><br><hr>
<h4>Please Log in To View The Main Page</h4></div>
<?=$this->form?> <!--here I want to display the form-->
<div><?php include APPLICATION_PATH.'/views/scripts/layouts/footer.php';?>
</div>
</body>
</html>
我得到的输出而不是表单是form?>
.
为什么是这样?我的代码有什么问题?请帮我。
提前致谢
查鲁