set value to field in model

hello!.

I have a register form and this fields:

ID => autonumeric (system)

USERNAME => string (user) *required

PASSWORD => string (user) *required

EMAIL => string (user) *required

GROUP => integer (system)

in rules :

public function rules()


{


    return array(


        array('username, password,email', 'required'),


        array('password', 'authenticate'),


    );


}

My question is, how i can specify a value to GROUP field manually in yii model?

Thanks!

You can set it in controller, for example:


	$model->attributes = $_POST['MyFancyForm'];

	$model->group = 30;

	$model->save();

nice, thanks dude

Another way: in your models you can use special function beforeSave




    protected function beforeSave()

    {

        if(parent::beforeSave()){

          if ($this->isNewRecord)            

            $this->group = 30;

          return true;

        }

        else

            return false;       

    }