Yii2:如何使验证规则消息不被编码?

时间:2014-05-11 16:12:51

标签: php yii2

在基础PasswordResetRequestForm模型中:

public function rules()
    {
        return [               
            ['email', 'exist',
                'targetClass' => '\common\models\User',
                'filter' => ['status' => User::STATUS_ACTIVE],
                'message' => 'Such user is not registered. '.BaseHtml::a('Signup.',['site/signup'])
            ],
        ];
    }

但链接渲染已编码。如何强制它不被编码?我应该在ActiveForm,字段配置或验证规则中执行哪些操作?

2 个答案:

答案 0 :(得分:4)

我不知道过去,但现在你可以在fieldConfig中配置它:

$form = ActiveForm::begin([
    'fieldConfig' => [
        'errorOptions' => ['encode' => false],
    ],
]);

答案 1 :(得分:0)

您可以在ActiveForm上配置:

<?php $form = ActiveForm::begin([
    'encodeErrorSummary' => false,
]); ?>

了解详情:http://www.yiiframework.com/doc-2.0/yii-widgets-activeform.html#$encodeErrorSummary-detail