Validate file only on create not update?

What is the best way to set a file for validate only on create… now I have in my model:


public function rules() {

        // NOTE: you should only define rules for those attributes that

        // will receive user inputs.

        return array(

            array('title, pdf', 'required'),

            array('title', 'length', 'max'=>125),

            array('description', 'safe'),

            array('pdf', 'file',

                'types'=> 'pdf',

                'maxSize' => 1024 * 1024 * 10, // 10MB

                'tooLarge' => 'The file was larger than 10MB. Please upload a smaller file.',

            ),

        );

    }

But this will require to upload a new file at update…

You can use scenarios in your validation rules, such as




array('pdf', 'file',

    'types'=> 'pdf',

    'maxSize' => 1024 * 1024 * 10, // 10MB

    'tooLarge' => 'The file was larger than 10MB. Please upload a smaller file.',

    'on' => 'insert',

),



Thank you, It worked for me.