Hello All,

I have a form with 2 fields and submit button.
Form is created like this:

$form = new Zend_Form();
$form->setMethod('post');
                
$form->addElement('text','field1', array(
                                        'label' => 'User Name',
                                        'required' => false
                                ));
$form->addElement('text','field2', array(
                                        'label' => 'Secret Code',
                                        'required' => false
                                ));
                
$form->addElement('submit','submit',array(
                                        'label'=>'Submit'
                                ));

I need to validate the form like this:
If a user submits the form with ALL empty fields the form should fail the
validation, but if a user fills in AT LEAST ONE of two fields the validation
should be successful.

How should I set up the validation for this?

Now I just check if at least one of the fields is filled in controller, and
display the error message. But I was thinking may be there is a way to
extend Zend_From or some validators  for this purpose as I've got several
forms like this.

Thanks in advance for any help.

-- 
View this message in context: 
http://www.nabble.com/Zend_Form-custom-validator-best-practices-tp19671713p19671713.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to