How can I safe my attributes for a massive assignment when I'm using a scenario (in my example 'update' scenario)?
Here is my rules:
public function rules()
{
return [
[['user_id', 'type', 'name', 'status'], 'required'],
[['country_id', 'address', 'name', 'status'], 'safe', 'on' => 'update'],
];
}
public function scenarios()
{
$scenarios = parent::scenarios();
$scenarios['update'] = ['user_id', 'type', 'name'];
return $scenarios;
}
When I'm checking the safe attributes in my controller using $model->safeAttributes(), I'm only getting the required attributes that are in the required of the 'update' scenario of the function scenarios().
And of course, the $model->load(Yii::$app->request->post()) function does not retreive other attributes.
How can I put them safe? Even if I want to add some other rules, I can't find the way!