Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2: How to make validation rule message not to be encoded?

Tags:

php

yii2

In base PasswordResetRequestForm model:

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'])
            ],
        ];
    }

But link renders encoded. How to force it not to be encoded? Where should I do it, in ActiveForm, in field config, or in validation rule?

like image 883
Anatoliy Gusarov Avatar asked May 11 '14 16:05

Anatoliy Gusarov


1 Answers

I don't know about the past, but now you can configure it in the fieldConfig:

$form = ActiveForm::begin([
    'fieldConfig' => [
        'errorOptions' => ['encode' => false],
    ],
]);
like image 162
yaser Avatar answered Oct 15 '22 17:10

yaser