I’m building a basic Zend_Form in Zend 1.12 to take birth dates and hire dates of new employees. I’d like to do a very basic validation on the dates – at this time I’m not concerned about nonsense dates like a February 30th; I just want to get ranges like 1900-9999, 1-12, 1-31 going on the individual input fields.
The form will load with the code below, but with a valid year (1982) or not (2), I get an application error on submission: “Missing option. ‘min’ and ‘max’ has to be given”
I think I’m not getting the syntax right.
$this->addElement('text', 'byear', array(
'label' => 'Birth Date :: Year:',
'required' => true,
'style' => 'width:75px;',
'filters' => array('StringTrim'),
'decorators' => array('Label',
'ViewHelper'),
'validators' => array(
array('Between', 1900, 9999))
));
This doesn’t work either:
'validators' => array(array('Between', 'min' => 1900, 'max' => 9999))
Try