Not update (ignore) certain fields in update action

Is there a way to not update (ignore) certain fields in Update action?

Of course:

  1. Display associated fields conditionally in your form, using yii\base\model::$scenario or yii\db\ActiveRecord::$isNewRecord.

  2. Important! Use scenarios to mark attributes as unsafe for mass assignment on update.

Thanks!! I’ll check it out!

You can also do it the opposite way: specify the exact fields that you want to update.




// validate and save only the email/username fields

$user->save(true, ["email", "username"]);



If you can do this, it would be easier/faster than setting up validation rules with scenarios.