6

I am trying to display a link in error message in login for, but it is not working.

The error message in LoginForm valdiation:

$this->addError($attribute, 'Your account has been disabled. <a href=""> Enable It</a>');

In login.php (view):

<?= $form->errorSummary($model); ?>

I tried like below, but not working:

 <?= $form->errorSummary($model,['errorOptions' => ['encode' => false,'class' => 'help-block']]); ?>

I am getting the following output instead of rendered a tag:

error summary

rob006
  • 18,710
  • 5
  • 41
  • 58
sridhar
  • 301
  • 2
  • 14

1 Answers1

10

You need to disable encoding at ActiveForm level using encodeErrorSummary property, if you want to use $form->errorSummary($model):

<?= $form = ActiveForm::begin([
    'id' => 'login-form',
    'encodeErrorSummary' => false,
    'errorSummaryCssClass' => 'help-block',
]) ?>

<?= $form->errorSummary($model) ?>

Alternatively you may use Html::errorSummary() directly:

<?= Html::errorSummary($model, ['encode' => false]) ?>
rob006
  • 18,710
  • 5
  • 41
  • 58