开发者

zend form with 2(two) Zend_Validate_Db_RecordExists, only one works

Hello i have a Zend Form with 2(two) Zend_Validate_Db_RecordExists toghether like this :

    $ditta_es开发者_开发技巧iste = new Zend_Validate_Db_RecordExists(
            array(
                'table' => 'ditta',
                'field' => 'id'
            )
    );

    $this->getElement('ditta')->setAttrib('id', 'nome_ditta')->setRequired(true);
    $this->getElement('ditta_id')->addValidator(new Zend_Validate_NotEmpty(), false)->addValidator($ditta_esiste, false);


    $marca_esiste = new Zend_Validate_Db_RecordExists(// ZEND IMBECILLE NON FUNZIONA QUESTO CONTROLLO
        'marca', 'id'
    );

    $this->getElement('marca_id')->addValidator($marca_esiste, false);

the second validator never triggers, i can put garbage in it's constructor and it woun't care


Zend framework doesn't allow two validators of the same class to be used on the same element... See This Bug Report (Read Comments Too)

A work around is to create your own validator class that extends Zend_Validate_Db_RecordExists and then use that as your second validator.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜