Answer the question
In order to leave comments, you need to log in
How to insert a hyperlink in addError in Yii2?
It would seem a simple question, how to put a link into validation, but in fact neither decoding nor conversion of HTML entities helps, that is, the usual built-in php functions, - "addError" - completely ignores Yii::$app->session->getFlash();
- does not see at all, without addError validation is ignored, that is in the end, we get the error text with the html code of the link at the output.
<?=Html::encode();?>
<?=Html::decode();?>
Answer the question
In order to leave comments, you need to log in
Actually, you can.
I didn't realize right away.
Here is how it should be done.
// В ActiveForm
$form->field($model, 'password',[
'errorOptions' => [
'encode' => false,
]
])->passwordInput()
// В модели
$this->addError('password', UsersModule::t('module', 'ERROR_WRONG_USERNAME_OR_PASSWORD', ['link' => Html::tag('a','test')]));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question