File Array Validation -> Is It Possible In Yii?

Hello together,

to validate a single file (a single input-file-field) is no problem in yii and it works very well:




public function rules() {

    return CMap::mergeArray(parent::rules(), array(

        array(

            'image', 

            'file', 

            'allowEmpty'=>false, 

            'types'=>'pdf,jpg,gif,png', 

            'on' => 'CaseA, CaseB', 

            'maxSize'=>1024000, 

            'tooLarge' => 'Max File size is 1MB', 

            'message' => 'You have to upload a file at least'

        ),

        ....

        ....




What if image is an array of files? Created Form-Elements by yii looks like (Firebug-Output):




<input type="file" id="MyFormModel[image][0]" name="MyFormModel[image][0]">

<input type="file" id="MyFormModel[image][1]" name="MyFormModel[image][1]">

What exactly should I modify in my rules? A simple "image[]" does not help…

Thank you very much

rgds

eb

you can use cmultifileupload widget I hope it helps you…

Check this option: http://www.yiiframework.com/doc/api/1.1/CFileValidator#maxFiles-detail

Thank you but I may not, it is a so given requirement…

ok you try andy_s link he is right…

Thank you, that is the solution