-- Sam Davey <[EMAIL PROTECTED]> wrote
(on Thursday, 10 July 2008, 06:46 AM -0700):
> I'm using Zend_Form and defining an element as follows:
>
> $this->addElement('text', 'username', array(
> 'validators' => array('alnum'),
> 'decorators' => $this->_themedTextDecorator,
> 'label' => 'Name',
> 'required' => true,
> 'class'=>'theme',
> ));
>
> The form validators are triggered correctly... but I am presented with the
> following errors. If I add another validator to the 'validators' array the
> error is repeated again.
>
> Warning: substr_compare() [function.substr-compare]: The start position
> cannot exceed initial string length in
> /home/sam/dolphin2008.co.uk/application/library/Zend/Form/Element.php on
> line 1097
>
> Why is this? Am I defining the validator wrong?
Please try using a current version from svn; I believe this should be
fixed at this point.
> Looking at the library code this is the code causing the problem
> public function getValidator($name)
> {
> if (!isset($this->_validators[$name])) {
> $validators = array_keys($this->_validators);
> $len = strlen($name);
> foreach ($validators as $validator) {
> if (0 === substr_compare($validator, $name, -$len, $len,
> true)) {
> return $this->_validators[$validator];
> }
> }
> return false;
> }
>
> return $this->_validators[$name];
> }
>
> Where is the $name coming from.... because its not from the 'validators'
> array... that sets the $validator string it compares against.
>
> Any ideas?
>
> The following post suggest suppressing the error but I don't want to start
> editing the library files.
>
> http://www.mail-archive.com/[email protected]/msg12912.html
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend Framework | http://framework.zend.com/