如何更改错误类(yii2表单)

时间:2015-11-01 12:19:53

标签: php html yii2

我有活跃的表格:

<? $form = ActiveForm::begin([
    'layout' => 'horizontal',
    'fieldConfig' => [
        'template' => "{input}\n{hint}\n{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(); ?>

如果用户输入了错误的数据,yii2会添加“has-error”类,但我需要“错误”类。我如何改变课程?我试图更改errorOptions的值,但它没有帮助。

2 个答案:

答案 0 :(得分:3)

我解决了问题

{{1}}

答案 1 :(得分:0)

你可以改变这一行:

'error' => 'help-inline' 

'error' => 'error-inline'