Reputation: 3556
I need to translate a label of an active form without changing the model.
This:
$form->label($model, 'myField', array('class' => 'title'))
Takes the translation by default from the translation.php in the protected/messages/lang/ folder.
Now I want the label to take the translation from another file (without changing the model). How would I do that? The docs are a little vague on what kind of variables I can pass to the label...
Upvotes: 1
Views: 856
Reputation: 2267
You can specify label
in the $htmlOptions
array:
http://www.yiiframework.com/doc/api/1.1/CHtml#activeLabel-detail
$form->label(
$model,
'myField',
array('class' => 'title', 'label' => Yii::t('myCategory', 'Field label'))
)
Yii::t()
method translates the given message from source language to target language. You can read more information about internationalization here:
http://www.yiiframework.com/doc/api/1.1/YiiBase#t-detail http://www.yiiframework.com/doc/guide/1.1/en/topics.i18n
Upvotes: 1