Zend 表单验证不起作用

Awa*_*rni 1 validation zend-framework

我创建了一个 zend 表单。我添加了一些元素。我已经在所有元素中放置了验证属性,但没有进行验证。这是我的代码

  /* Form Elements & Other Definitions Here ... */
    $this->setMethod('post');
   $this->addElement('text', 'email', array(
       'required'   => true,
        'filters'    => array('StringTrim'),
        'validators' => array(
            'EmailAddress',
        )
    ));
   // Add the comment element
    $this->addElement('textarea', 'comment', array(
       // 'label'      => 'Please Comment:',
        'required'   => true,
        'validators' => array(
            array('validator' => 'StringLength', 'options' => array(0, 20))
            )
    ));

    // Add a captcha
    $this->addElement('captcha', 'captcha', array(
        //'label'      => 'Please enter the 5 letters displayed below:',
        'required'   => true,
        'captcha'    => array(
            'captcha' => 'Figlet',
            'wordLen' => 5,
            'timeout' => 300
        )
    ));

    // Add the submit button
    $this->addElement('submit', 'submit', array(
       'ignore'   => true,
        'label'    => 'Sign Guestbook',
    ));

    // And finally add some CSRF protection
    $this->addElement('hash', 'csrf', array(
        'ignore' => true,
    ));
Run Code Online (Sandbox Code Playgroud)

在锻炼中甚至没有一次验证。在我看来,我只是echo表单对象。有没有人告诉我我错在哪里?

din*_*pmi 5

Zend_Form应该在服务器端验证您的输入。要使用它,您需要以某种方式将数据发送到服务器,然后调用$form->isValid($data).

在任何情况下,请记住验证始终在服务器端运行。

希望有所帮助,