2015-04-12 130 views
1

我在普通/消息的翻译串/ EN-US /前端/ quicksignup为:Yii2渲染翻译字符串中的HTML标签

return [ 
    'AcceptTermsAndConditionLabel' => 'I confirm that I am more than 13 years old and accept the {terms and condition}, and {privacy policy} of this website', 
]; 

QuickSignupForm模型的样子:

public function attributeLabels() 
{ 
    return [ 
     'AcceptTermsAndCondition' => Yii::t('frontend/quicksignup','AcceptTermsAndConditionLabel'), 

    ]; 
} 

它呈现以下内容:

I confirm that I am more than 13 years old and accept the {terms and condition}, and {privacy policy} of this website 

我想用链接替换{terms and condition}{privacy policy}。但是,当我在我的可翻译文件中尝试这样做时,例如common/messages/en-Us/frontend/quicksignup它会以字符串形式呈现。

下面是输出的屏幕截图。我如何呈现链接?有任何想法吗?

enter image description here

回答

2

我找到解决方案。在ActiveField中使用label方法并设置format=>raw选项。这样的代码:

<?= $form->field($model, 'rememberMe')->checkbox()->label(Yii::t('app', 'I confirm that I am more than 13 years old and accept the {terms and condition}, and {privacy policy} of this website', ['privacy policy'=> 
     Html::a('111', '/asd/')]), ['format' => 'raw']) ?> 

此解决方案有一个减号。您必须设置两次标签:模型和表单。

+0

工作就像魅力:)感谢你保存了我的一天! – Chinmay