Yii2 非数据库(或虚拟)属性在大规模分配期间未填充?

Yii2 non-DB (or virtual) attribute isn't populated during massive assignment?

我已经定义了一个虚拟属性:

class ContactForm extends Model {

    public $name; // is not a DB field

我注意到它在大量分配期间没有填充(提交表格后,在 $model->load($_POST) 中)。它可以以某种方式与数据库属性一起填充吗?还是我做错了一些没有填充但应该填充的错误?谢谢!

文档:Massive Assignments

Like normal models, Active Record instances also enjoy the massive assignment feature. Using this feature, you can assign values to multiple attributes of an Active Record instance in a single PHP statement, like shown below. Do remember that only safe attributes can be massively assigned, though.

文档:Safe Attributes

For this reason, a special validator aliased safe is provided so that you can declare an attribute to be safe without actually validating it. For example, the following rules declare that both title and description are safe attributes.

如果您没有任何验证需求,您必须对您的属性进行某种验证 - 将其定义为 safe

public function rules()
{
    return [
        [['name'], 'safe'],
    ];
}