3
<?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 验证。

谢谢

4

1 回答 1

5

这是我的做法:

$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);
于 2009-08-12T12:31:16.690 回答