I'm writing a custom validator that checks that at least one field has a value. I want to validate that either 'namefield' or 'idfield' has a value. One of them can be empty, or both can have a value, but at least one of them must have a value.
$nameField = new Zend_Form_Element_Hidden('namefield');
$nameField->setValue($this->nameFieldValue)
->addValidator('AtLeastOneHasValue', false, array('idfield'));
From what I understand, my validator will not validate unless I set my form element to required.
->setRequired(true)
But if I set it to required, it automatically validates that it is not empty, and the error message says that it is empty. I want to allow the field to be empty, and validate multiple fields with my custom validator. How do I validate a form element with my custom validator, without setting the form element to required?