I have to create my custom FORM:isvalid()
function in my form
like below, because I have to check if one of these 2 fields are at least filled out:
class Products_AddForm extends Zend_Form {
public function isValid($data)
{
// Check special post data
$pzn_val = $data['PZN'];
$mar_val = $data['PZO'];
if(empty($pzn_val) && empty($mar_val)) {
$this->getSubForm('sub1')->getElement('PZN')->setErrors(array('PZN or PZO needed'));
$this->getSubForm('sub2')->getElement('PZO')->setErrors(array('PZN or PZO needed'));
}
// Standard validation
return parent::isValid($data);
}
The errors for PZN
and PZO
will only fire if another error (other field) will be found.
How can I get the form error
?
Field PZN
and PZO
are defined as not required
.
TIA Matt