I'm trying to do data transformation on an attribute by using the setter method setUsr_firstname
for an attribute that is named usr_firstname
.
class User extends ActiveRecord implements IdentityInterface {
public function rules() {
return [
[['usr_firstname', 'usr_lastname', ... ], 'required'],
...
];
}
...
public function setUsr_firstname($value) {
$this->usr_firstname = fix_wrong_title_case($value);
}
}
Then I do the following:
$model = new User(['scenario' => User::SCENARIO_REGISTER]);
$model->usr_firstname = 'John';
But the setter method is never called! I have tried naming the method all kinds of things - eg. setUsrFirstname
- but nothing works. How do I get this to work?
UPDATE
Figured out it doesn't work for any ActiveRecord attribute, with or without an underscore in the attribute name.