2

After assigning all required values to user model (column which i have added also). When I am using $model->save() data for all default attributes getting saved except the one I have added. I trying insert via REST call. If there is any other way to do please let me know. I have also followed this link https://github.com/dektrium/yii2-user/blob/master/docs/adding-new-field-to-user-model.md which is of no use.

this is my rules method in users model

public function rules()
{
    return [
        [['username', 'email'], 'filter', 'filter' => 'trim'],
        [['username', 'email', 'status','name'], 'required'],
        ['email', 'email'],
        ['username', 'string', 'min' => 2, 'max' => 255],

        // password field is required on 'create' scenario
        ['password', 'required', 'on' => 'create'],
        // use passwordStrengthRule() method to determine password strength
        $this->passwordStrengthRule(),

        ['username', 'unique', 'message' => 'This username has already been taken.'],
        ['email', 'unique', 'message' => 'This email address has already been taken.'],
    ];
}

Thank you.

akhil
  • 347
  • 1
  • 3
  • 16
  • Maybe you forgot to add the new column to the model rules? If "name" is in rules please post your rules and the rest of the code. Why REST? – Fory Dec 16 '15 at 20:31
  • I am registering user via rest call passeing data through post method – akhil Dec 17 '15 at 04:38

1 Answers1

0

User model which I was using extended from UserIdentity So I have added rules method in UserIdentity class but after adding new column to users table, that column should be specified in rules method of users model only which ever it might be extending. Previously there was no need of adding like this till Yii v2.1.0 may be in Yii 2.2.0 it has to be.

akhil
  • 347
  • 1
  • 3
  • 16