I have active form:
<? $form = ActiveForm::begin([
'layout' => 'horizontal',
'fieldConfig' => [
'template' => "{input}
{hint}
{error}",
'horizontalCssClasses' => [
'error' => 'help-inline',
'hint' => '',
],
],
]);
?>
<div class="control-group">
<b>Регистрация</b>
</div>
<?
echo $form->field($model, 'login', ['options' => ['tag' => 'div', 'class' => 'control-group'],'inputOptions' => array('placeHolder' => 'Логин')]);
echo $form->field($model, 'password', ['options' => ['tag' => 'div', 'class' => 'control-group'],'inputOptions' => array('placeHolder' => 'Пароль')]);
echo $form->field($model, 'repassword', ['options' => ['tag' => 'div', 'class' => 'control-group'], 'inputOptions' => array('placeHolder' => 'Повторите пароль')]);
?>
<? ActiveForm::end(); ?>
If user has entered the wrong data, yii2 adds 'has-error' class, but i need 'error' class. How i can change class? I tried to change value of errorOptions but it did not help.
</div>
you can change this line :
'error' => 'help-inline'
to
'error' => 'error-inline'
I solved the problem
<? $form = ActiveForm::begin([
'layout' => 'horizontal',
'fieldConfig' => [
'template' => "{input}
{hint}
{error}",
'horizontalCssClasses' => [
'error' => 'help-inline',
'hint' => '',
],
],
'errorCssClass' => 'error'
]);
?>
</div>