Yii2 отображает тег html внутри строки перевода

У меня есть переводимая строка в 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} и {privacy policy} ссылками. Но когда я пытаюсь сделать это в моем переводимом файле, то есть common / messages / en-Us / frontend / quicksignup, он отображается в виде строки.

Ниже приведен снимок экрана с результатами. Как я могу отобразить ссылки? Любые идеи?

введите описание изображения здесь


person Chinmay Waghmare    schedule 12.04.2015    source источник


Ответы (1)


Я нахожу решение. Используйте метод 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']) ?>

У этого решения есть один минус. Вы должны установить метку дважды: в модели и в форме.

person vitalik_74    schedule 13.04.2015
comment
Работает как шарм :) Большое спасибо, что спасли мне день !! - person Chinmay Waghmare; 13.04.2015