zend表格没有显示

时间:2017-02-08 13:56:02

标签: php html forms zend-framework

您好我正在开发一个PHP应用程序,我正在使用Zend Framework,我是新手。

我的问题是我无法在视图中打印表单。我有一个包含表单的文件,一个将标题传递给视图和视图的控制器。

视图的标题显示正确,但表单未显示。

这是我的代码,

FORM

class forms_UploadOtticaForm extends Zend_Form 
{ 
    public function __construct($options = null) 
    { 
        parent::__construct($options);
        $this->setName('contact_us');

        $title = new Zend_Form_Element_Select('title');
        $title->setLabel('Title')
              ->setMultiOptions(array('mr'=>'Mr', 'mrs'=>'Mrs'))
              ->setRequired(true)->addValidator('NotEmpty', true);

        $firstName = new Zend_Form_Element_Text('firstName');
        $firstName->setLabel('First name')
                  ->setRequired(true)
                  ->addValidator('NotEmpty');

        $lastName = new Zend_Form_Element_Text('lastName');
        $lastName->setLabel('Last name')
                 ->setRequired(true)
                 ->addValidator('NotEmpty');

        $email = new Zend_Form_Element_Text('email');
        $email->setLabel('Email address')
              ->addFilter('StringToLower')
              ->setRequired(true)
              ->addValidator('NotEmpty', true)
              ->addValidator('EmailAddress'); 


        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Contact us');

        $this->addElements(array($title, $firstName, 
            $lastName, $email, $submit));

    } 
}

控制器:

  class UploadOtticaController extends Zend_Controller_Action
  {
    function indexAction()
    {
        $this->view->pageTitle = "Zend_Form Example";
    }
  }

查看:

<?php echo $this->pageTitle ;?>

<?php echo $this->form ;?>

我该如何解决?

由于

0 个答案:

没有答案