Issues

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

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:


validators.regexp.validator = "Regex"
validators.regexp.options.regex = "/[a-z]{2,}/"

This will then work.

Marked as "not an issue" as it was a matter of an incorrect configuration file.