ZF-5122: Required flag set to true doesn't work for checkbox element.
$form = new Zend_Form; $form->setMethod('post'); $form->addElement('checkbox', 'identityVerified', array('required' => true, 'value' => 'confirmed')); var_dump($form->identityVerified->getValue());
string '0' (length=1)
but isValid() should be false when no value was passed an required flag=true, like docs suggests: "By default, if an element is required, but does not contain a 'NotEmpty' validator, isValid() will add one to the top of the stack, with the breakChainOnFailure flag set. This makes the required flag have semantic meaning: if no value is passed, we immediately invalidate the submission and notify the user, and prevent other validators from running on what we already know is invalid data."
I understand that checkbox element evaluates to 0 when it's not checked, an that's why required=true doesn't trigger validation error. If so, what's the point of using "required" param for checkbox element? Maybe using "required" flag for this form element should throw an excepion "No such flag".