ZF-6357: Fatal Error when validating a Zend_Form_Element_* with a Regex validator and configuration set via a Zend_Config object

Issue Type: Bug Created: 2009-04-20T15:28:38.000+0000 Last Updated: 2009-04-20T16:10:09.000+0000 Status: Resolved Fix version(s): Reporter: Mathias DESLOGES (freakdev) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Form

Related issues: Attachments:


Sample code :

<pre class="literal">
$config = new Zend_Config_Ini('config.ini');

$test = new Zend_Form_Element_Text('myElement');


ini file content :

<pre class="literal">
validators.regexp.validator = "Regex"
validators.regexp.options = "/[a-z]{2,}/"

Error :

<pre class="literal">
Fatal error: Cannot unset string offsets in C:\Program Files\Zend\ZendServer\share\ZendFramework\library\Zend\Form\Element.php on line 2004


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:

<pre class="highlight">
validators.regexp.validator = "Regex"
validators.regexp.options.regex = "/[a-z]{2,}/"

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.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.