views:

789

answers:

1
<?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 .....

please help with modifying above code to apply GreaterThan validation.

Thanks

+1  A: 

Here's how I'd do it:

$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);
Richy C.
thanks for reply, can you please tell me how will you modify the code above to do the same thing.
Ish Kumar
Basically replace where you have the $this->addElement... line with my block.
Richy C.