I have a model class, and i use it in many views.
class Translations extends CActiveRecord
{
...
public function attributeLabels()
{
return array(
'row_id' => 'Row',
'locale' => 'Locale',
'short_title' => 'Short Title',
'title' => 'Title',
'sub_title' => 'Sub Title',
'description' => 'Description',
'content1' => 'Content1',
'content2' => 'Content2',
'com_text1' => 'Com Text1',
'com_text2' => 'Com Text2',
'com_text3' => 'Com Text3',
'com_text4' => 'Com Text4',
'com_text5' => 'Com Text5',
'com_text6' => 'Com Text6',
);
}
...
}
Can i change model attributes labels value for each view?
You could declare a scenario for the model depending on which view you are going to use and define the params according to the scenario? Lets say your different views are for different people:
Then in your controller for each person you can define the scenario, eg;
Then in the view after declaring ‘PersonA’ as the scenario you’d see the label for
myFieldas ‘My Label for PersonA’