ZF-6357: Fatal Error when validating a Zend_Form_Element_* with a Regex validator and configuration set via a Zend_Config object
Description
Sample code :
$config = new Zend_Config_Ini('config.ini');
$test = new Zend_Form_Element_Text('myElement');
$test->setConfig($config);
$test->isValid('test');
ini file content :
validators.regexp.validator = "Regex"
validators.regexp.options = "/[a-z]{2,}/"
Error :
Fatal error: Cannot unset string offsets in C:\Program Files\Zend\ZendServer\share\ZendFramework\library\Zend\Form\Element.php on line 2004
Comments
Posted by Matthew Weier O'Phinney (matthew) on 2009-04-20T16:09:32.000+0000
Options for any validator are expected to be an array, and they are passed in order as arguments to the validator constructor (keys are thus arbitrary). Change your config to the following:
This will then work.
Posted by Matthew Weier O'Phinney (matthew) on 2009-04-20T16:10:08.000+0000
Marked as "not an issue" as it was a matter of an incorrect configuration file.