Answer the question
In order to leave comments, you need to log in
How to display error in yii2 form in right place?
It is necessary to display input errors above the registration form and not below the fields, and preferably in the
bootstrap alert component
<div class="alert alert-danger" role="alert">...</div>
$form = ActiveForm::begin(['id' => 'login-form',
'options' => ['class' => 'form-horizontal'],
'fieldConfig' => [
'template' => '
<div class="alert alert-danger" role="alert">{error}</div>
{label}<div class="col-sm-10"></div><div class="col-sm-10">{input}</div>',
'labelOptions' => ['class' => 'col-sm-2 control-label'],
],
Answer the question
In order to leave comments, you need to log in
If the data has not been validated, use \Yii::$app->session->setFlash()
it to add error texts.
And above the form, use the Alert widget https://github.com/yiisoft/yii2-app-advanced/blob/...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question