I am trying to replace data in my grid view, but I can seem to get it to work. My data field ‘userroles’ is set as numerical Values, in my code I would like to replace the values with labels to represent the data.
I created a method in the controller call getValues()
public function getValues($id){
switch ($id) {
case 1: $role = "'User'"; break;
case 2: $role = "'Tech'"; break;
case 3: $role = "'SuperTech'"; break;
case 4: $role = "'Admin'"; break;
break;
default: $role = "'No Role Selected'"; break;
}
return $role;
}
And in my Grid View I have…
array(
'name' => 'userRoles',
'value' => $this->getValues($model->userRoles),
),
//'admin_disabled',
If I change return $roles to return $id I get the correct Values back, So I know I am passing the correct values. All I get back is No Role Selected.