开发者

Validators are not working anymore in Zend Framework?

Eariler I happily used the following code for creating form elements (inside Zend_Form descendant):

        //Set for options
        $this->setOptions(array(
            'elements' => array(
                'title' => array(
                    'type' => 'text',
                    'options' => array(
                        'required' => true,
                        'label' => 'Title',
                        'filters' => arra开发者_高级运维y('StringTrim'),
                        'validators' => array(
                                array('StringLength', false, array('minLength'=>1, 'maxLength'=>50)),
                        ),
                   )
                )

));

But now I've noticed that validators are not working.. I suspect this might be due to zend updates..

Does anyone face this problem?


I'm not sure if there was an API change that affected this or not, but the syntax I use is:

$this->addElements(array(
    array('text', 'title', array(
        'required'   => true,
        'label'      => 'Title',
        'filters'    => array('StringTrim'),
        'validators' => array(
                array('StringLength', false, array('min'=>1, 'max'=>50)),
        ),
    )),
));

Edit: updated the StringLength validator options keys

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜