assign scenario based on update values (Need or not)
// When add create, We have to give password and password
$model=new User;
$model->scenario ='insert';
...
$model->save();
//When update use update scenario, We dont need to give password
$model=User::model()->findByPk($id);
$model->scenario ='updateuser';
In model
---------
array('username, password,confirmpassword,firstname,lastname', 'required','on'=>'insert'),
array('username, firstname,lastname', 'required','on'=>'update '),
I explained What i understood. your form have two fields fileupload, theurlurl. So You must have to choose one of the field. Better way to write custom validation function in model.
public function my_required($attribute_name,$params){
if((isset($this->fileupload) && $this->fileupload!='') && (isset($this->theurl) && isset($this->theurl))){
$this->addError('fileupload','AddError');
}
}
public function beforeValidate() {
if (!$this->myfile && !$this->urlfile) {
$this->addError('myfile', 'You have to fill the url or upload a file');
}
return parent::beforeValidate();
}