编程语言
首页 > 编程语言> > php-添加验证GreaterThan-Zend表单

php-添加验证GreaterThan-Zend表单

作者:互联网

<?php
class Form_Audience extends Zend_Form_SubForm
{
    public function init()
    {
        $this->setMethod('post');
        $this->setLegend('Audience Details');

        $this->addElement('text', 'audience_total', array(
            'label'      => 'Audience Total :',
            'required'   => true,
            'filters'    => array('Digits'),
            'size'       => 15,
            'validators' => array(
                    'Digits',
                )
            ));


.... remaining code .....

请帮助修改上述代码以应用GreaterThan验证.

谢谢

解决方法:

这是我的处理方式:

$eElement=new Zend_Form_Element_Text('audience_total');
$eElement->setLabel('Audience Total');
$eElement->setRequired(true);
$eElement->setFilters(Array('Digits'));
$eElement->size(15);
$validator=new Zend_Validate_Digits();
$eElement->addValidator($validator,true);
$validator=new Zend_Validate_GreaterThan(1);
$eElement->addValidator($validator,true);
$this->addElement(true);

标签:zend-validate,zend-framework,php
来源: https://codeday.me/bug/20191107/2003183.html