Thanks, pestaa.
Maybe there’s a little misunderstanding. You can do massive assignment in every scenario. And with safeAttributes() you define which attributes are safe in which scenario. If you always have the same safe attributes, no matter wich scenario, then simply don’t use any scenario in safeAttributes:
public function safeAttributes() {
return array('type','description','bizrule','data');
}
A more thorough example:
Let’s say you have a AR User with attributes id, username, firstname, lastname, password, remarks. You want to use it in three different scenarios:
- Registration
Here username, firstname lastname and password should be massively assigned. But not id, as bad users could spoil the id on submission.
- Login
Only username and password shall be safe here.
- Admin/User management
All attributes except id should be safe in this scenario.
The according safeAttributes() could look like this:
public function safeAttributes() {
return array(
// the "default" safe attributes, valid if no scenario is specified.
// in our case this could be used for admin/user management.
// Simply don't specify any scenario when creating the model object.
'username,firstname,lastname,password,remarks',
'registration' => 'username,firstname,lastname,password',
'login' => 'username,password',
);
}