notexists

This validator validates the absence of requested file.
2 followers

This validator validates the absence of requested file and optionally you can rename the $object->$attribute and save the file using the $object->$attribute.

  • Properties :
    1. string $path the path to look up
    2. boolean $renameIfExists can be used to rename the $object->$attribute if the file already exists. Defaults to true.
    3. boolean $allowEmpty can be used to set allow empty file upload. Defaults to true
    4. string $emptyMessage can be used to display error when file is empty
    5. string $existMessage can be used to display error when file already exists

Requirements

Yii 1.1

Installation and Usage

  1. Copy this validator to protected/extensions

  2. Inside rules() of your model use like this : array('file','ext.validator.NotExists','path'=>'images/','allowEmpty'=>false,'renameIfExists'=>false,'emptyMessage'=>'{attribute} is empty','existMessage'=>'{value} already exists'),

...you can use the validator like the following...

public function rules()
    {
        return array(
            ....
            ....        array('file','ext.validator.NotExists','path'=>'images/','allowEmpty'=>false,'renameIfExists'=>false,'emptyMessage'=>'{attribute} is empty','existMessage'=>'{value} already exists'),
            ....
            ....
        );
    }

Total 2 comments

#14240 report it
Ahamed Rifaideen at 2013/07/29 02:56pm
How is it?

hi guys does it works as expected?

#14189 report it
Dhamodharan R at 2013/07/25 06:00am
Great !!

Nice one.

Leave a comment

Please to leave your comment.

Create extension