the problem is that the model attributes don’t update with the new value in $_POST[‘Role’] and always show the original values.
Trying to figure out why I go to the model rules and noticed that by default the IDRole attribute is not listed because, i guess, it normally wont receive user inputs.
So I added the IDRole to the rules marking it as required and numeric and all is working right.
the $role->attributes are correctly updated, but I cannot figure out why I need to mark my fields as required to accomplish my task.
You don’t have to have them required, you could mark them as ‘safe’ in the rule instead which would allow them to update if present, but not require that they be filled in.
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('Ruolo, IDRole', 'required'),
array('Tipo, IDRole', 'numerical', 'integerOnly'=>true),
array('Ruolo', 'length', 'max'=>50),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('IDRole, Ruolo, Tipo', 'safe', 'on'=>'search'),
);
}
If I leave only the safe attribues uncommented it doesn’t work.