exist validator

Hello from Ukraine :wink:

Does anyone can help me?

I’d tried to use ‘exist’ validator but I always get exception with next message

"Property "CExistValidator.0" is not defined."

please provide me correct example for rules.

all advices will be appreciated

thanks

Post your code please. Also see here.

That’s strange

I’d tried to use exist validator today and exception happened only 2 - 3 times and then it had disappeared.

But I’ve noticed that exception rised not during insert_post but after redirecting to the /post/view/<id>.

At the moment I can’t reproduce this strange behaviour.

My code




    public function rules() {

        return array(

            array('title', 'required'),

            array('content, idParent, category, tags', 'required', 'on'=>'insert_post'),

            array('idParent', 'exist', 'on'=>'insert_post', 'attributeName'=>'id', 'className'=>'Post'),

            array('idUser, idCategory, status, type, order, idParent', 'numerical', 'integerOnly'=>true), // !XXX: can be deleted in release

            array('commentsAllowed, pingable, withoutPurification', 'boolean'),

            array('category, title, content, tags, commentsAllowed, pingable,withoutPurification', 'safe'),

            array('order', 'safe', 'on'=>'insert_page'),

            array('idParent', 'safe', 'on'=>'insert_post'),

            array('id, idUser, idCategory, title, created, updated', 'safe', 'on'=>'search'),

        );

    }



Do you need to include the


'skipOnError'=>true,

For the exist array?