Hi,

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?

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/fw-general@lists.zend.com/msg12912.html

Thanks,

Sam
-- 
View this message in context: 
http://www.nabble.com/Zend_Form-validator-substr_compare-error-tp18382953p18382953.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to