【问题标题】:Rendering Zend_Form (white screen)渲染 Zend_Form(白屏)
【发布时间】:2023-03-11 18:14:01
【问题描述】:

我在 forms/user.php 中创建简单的表单:

class Form_User extends Zend_Form
{
        public function  __construct() {

        parent::__construct();
        $this->setName('form_user');

        $username = new Zend_Form_Element_Text('username');
        $password = new Zend_Form_Element_Password('password');
        $email = new Zend_Form_Element_Text('email');
        $submit = new Zend_Form_Element_Submit('submit');

        $this->addElements(array($username, $password, $email, $submit));
    }
}

我的控制器代码是:

    public function registrationAction()
    {
        $this->view->title = 'Reg new acc!';
        $this->view->headTitle($this->view->title, 'PREPEND');

        $form = new Form_User();
        $this->view->form = $form;

//     $this->view->form = 'test';
    }

<?php echo $this->form; ?> 当我渲染我的表单时,什么都没有发生,只有白屏。 当我在控制器$this->view->form = 'test'; 中使用此代码进行渲染时,它会显示“测试”文本。怎么办?

【问题讨论】:

  • 也许 $form = new Application_Form_User() ? ;)
  • 对不起,我的错误 - 没有 Application_...

标签: php zend-framework zend-form


【解决方案1】:

您可能已经关闭了error_reportingdisplay_errors,因此当您尝试实例化Form_User(应该是Application_Form_User)时不会看到致命错误。

【讨论】:

  • 索引文件中出现错误 error_reporting(E_ALL|E_STRICT); ini_set('display_errors', 'on');
  • application.ini 中的设置是什么?引导程序可以推翻您在 index.php 中设置的内容
  • 新建项目后的标准设置