1

我在common/messages/en-Us/frontend/quicksignup中有一个可翻译的字符串:

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}​​and {privacy policy}。但是,当我尝试在我的可翻译文件(即common/messages/en-Us/frontend/quicksignup)中执行此操作时,它会呈现为字符串。

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

在此处输入图像描述

4

1 回答 1

2

我找到解决方案。使用label方法ActiveField和设置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']) ?>

该解决方案有一个减号。您必须设置标签两次:在模型中和在形式中。

于 2015-04-13T11:06:24.397 回答