1
我已经创建了一个Zend形式。我添加了一些元素。我已经在所有元素中加入了验证属性,但验证没有解决。 这里是我的代码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,
));
甚至没有制定出一个单一的验证。在我看来,我只是echo
表单对象。任何机构会告诉我我在哪里错了?
只是要确定...你是否在代码中的任何地方调用'$ form-> isValid()'? – dinopmi
@dinopmi'$ form-> isValid'不会用于服务器端验证吗?还可以告诉我,上面的验证代码将用于服务器端验证或客户端验证 –
没关系,我只是重复dinopmi在他的回答中所说的... – jhuet