Unset attr before Validate

How can I unset file attr before validate ?

$tender_form->attributes=$_POST[‘TenderForm’];

if(!$tender_form->validate(array(‘file’)))

… -> in this place I want unset attr file not to be validate below

unset($tender_form->file); -> create error

if($tender_form->validate())

class TenderForm extends CFormModel

rules

array(‘file’, ‘file’, ‘types’=>‘zip, doc, rar, docx, xls, xlsx, txt’, ‘allowEmpty’=>true),

Sorry for broken english

Or another way to validate ?

So you want to validate first the file… do something with the file and then validate all other attributes…

Why don’t you validate all together with

if($tender_form->validate())

and then put all your code inside…

Anyway for unsetting an model attribute you can use unsetAttributes() - http://www.yiiframework.com/doc/api/CModel#unsetAttributes-detail

It’s right I want to validate first the file… do something with the file and then validate all other attributes…

unsetAttributes() doesn’t help

Nobody can help you if you don’t write why it does not help…

does it not unset the attribute? DO you get an error? Have you passed the parameter as an array?

Anyway… have you considered all the posibilities like:

you validate the file… do something with the file (maybe save it)… and then you validate other attributes…

what will you do if the validation of other attributes fails but you already processed the uploaded file…

what if the user after getting the validation errors for other attributes decides not to complete the form and just leaves…

Can you post your code?

Sorry for don’t write don’t write why it does not help…

if I make unsetAttributes(array(‘file’));

$tender_form->validate()

it validate attr file anywhere

unsetAttribute works because it unsets the attribute file…

but

$model->validate() will still validate all attributes…

if you don’t want to validate one attribute then you have all other attributes as parameters without the file attribute

Thank you for replay I have this idea at the beginning and realise but want to now another way