Details
Description
In a subclass of a form, I have the following code:
$this->addElement('text', 'from', array(
'label' => 'From',
'required' => true,
'validators' => array('digits', array('greaterThan', false, 0)),
'size' => 15,
));
$this->addElement('text', 'to', array(
'label' => 'To',
'required' => true,
'validators' => array('digits', array('greaterThan', false, 1)),
'size' => 15,
));
This leads to the following warnings:
Warning: Missing argument 1 for Zend_Validate_GreaterThan::__construct(), called in D:\Projects\...\...\library\Zend\Form\Element.php on line 2000 and defined in D:\Projects\...\...\library\Zend\Validate\GreaterThan.php on line 68
Call Stack
- Time Memory Function Location
1 0.0739 90776 {main}( ) ..\index.php:0
2 0.2249 4957736 Zend_Controller_Front->dispatch( ???, ??? ) ..\index.php:54
3 0.2350 5316368 Zend_Controller_Dispatcher_Standard->dispatch( ???, ??? ) ..\Front.php:934
4 0.2544 5690424 Zend_Controller_Action->dispatch( ??? ) ..\Standard.php:285
5 0.2545 5692328 TestController->geocodeAction( ) ..\Action.php:503
6 0.3275 8391568 Zend_Form->isValid( ??? ) ..\TestController.php:38
7 0.3277 8393664 Zend_Form_Element->isValid( ???, ??? ) ..\Form.php:1987
8 0.3279 8396472 Zend_Form_Element->getValidators( ) ..\Element.php:1283
9 0.3317 8476808 Zend_Form_Element->_loadValidator( ??? ) ..\Element.php:1210
10 0.3338 8495256 Zend_Validate_GreaterThan->__construct( ??? ) ..\Element.php:2000
( ! ) Notice: Undefined variable: min in D:\Projects\...\...\library\Zend\Validate\GreaterThan.php on line 70
Call Stack
# Time Memory Function Location
1 0.0739 90776 {main}( ) ..\index.php:0
2 0.2249 4957736 Zend_Controller_Front->dispatch( ???, ??? ) ..\index.php:54
3 0.2350 5316368 Zend_Controller_Dispatcher_Standard->dispatch( ???, ??? ) ..\Front.php:934
4 0.2544 5690424 Zend_Controller_Action->dispatch( ??? ) ..\Standard.php:285
5 0.2545 5692328 TestController->geocodeAction( ) ..\Action.php:503
6 0.3275 8391568 Zend_Form->isValid( ??? ) ..\TestController.php:38
7 0.3277 8393664 Zend_Form_Element->isValid( ???, ??? ) ..\Form.php:1987
8 0.3279 8396472 Zend_Form_Element->getValidators( ) ..\Element.php:1283
9 0.3317 8476808 Zend_Form_Element->_loadValidator( ??? ) ..\Element.php:1210
10 0.3338 8495256 Zend_Validate_GreaterThan->__construct( ??? ) ..\Element.php:2000
This obviously has to do with PHP treating 0 as empty().
I guess that other validators, at least lessThan, but others probably as well, also suffer from this bug.
The GreaterThan validator has no problems with "0".
Even unittests exist for testing this value.
As there is wether an empty() nor an other method call within the GreaterThan validator, I expect that the main problem is within Zend_Form, and not Zend_validate_GreaterThan.
Also the given failure message let me expect this.
A not given parameter, as returned within the php exception, is not a case which could be handled by the class itself.