2015-04-12 62 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