Failed To Assign Unsafe Attribute

Question: "Why handle field if it is not described in the model, and write to the log error".

public function rules()


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

    // will receive user inputs.

    return array(

        array('email, password', 'required', 'on' => 'registration'),

        array('is_real', 'numerical', 'integerOnly'=>true),

        array('email', 'length', 'max'=>150),

        array('cat', 'length', 'max'=>255),

        array('password', 'length', 'max'=>32),

        // The following rule is used by search().

        // Please remove those attributes that should not be searched.

        array('id, email, cat, password, is_real', 'safe', 'on'=>'search'),




Failed to assign unsafe attribute "region_id" class "RegistrationUser".

[color="#006400"]/* moved from Bug Discussions as that forum is for bugs in Yii, not bugs in your own code */[/color]

I would like to know where the error in my code

You did not make a rule for it.

So either make one, or mark it as a safe attribute. See the docs if you’re unsure about how to do this.

BTW: sometimes I only have time to moderate. ;)

Yes all right I’m not prescribed to him validation! Because it’s a fake field, which was not there.

The main question: How not to handle the fields on which are described in the model, which will improve productivity and similar errors.

If it’s a fake field then it probably belongs in a FormModel, not a Model. :)

Yes exactly.

The task of such

  1. Make the registration form

There will be 2 forms on the type of user.

  1. it’s Safe to pass values from the form in the model, so there was no error as it is now.

  2. And save)

And there’s 2 problems

  1. the Form of the grant error when processing is not described fields(fakes)

  2. the Model of the form takes extra fields that do not need her