Home > Backend Development > PHP Tutorial > Yii2 在场景中,如何限制某场景只能更新某些字段?

Yii2 在场景中,如何限制某场景只能更新某些字段?

WBOY
Release: 2016-06-06 20:20:07
Original
1802 people have browsed it

这个YII1版本有这样的功能,YII2中如何设置?

回复内容:

这个YII1版本有这样的功能,YII2中如何设置?

应该就是利用 scenario 来实现,只有在当前 scenario 下的attribute才能被块赋值,所以假定现在Model的blabla 那么在 $model->load 或者 使用 $model->setAttributes 进行赋值的时候,只有当前 secnario` 下的属性「safe attribute」被赋值

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template