gpt4 book ai didi

php - 如何更改错误类(yii2 形式)

转载 作者:行者123 更新时间:2023-12-04 02:16:26 26 4
gpt4 key购买 nike

我有事件表格:

<? $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' 类,但我需要 'error' 类。我怎样才能改变类?我尝试更改 errorOptions 的值,但没有帮助。

最佳答案

我解决了这个问题

<? $form = ActiveForm::begin([
'layout' => 'horizontal',
'fieldConfig' => [
'template' => "{input}\n{hint}\n{error}",
'horizontalCssClasses' => [
'error' => 'help-inline',
'hint' => '',
],
],
'errorCssClass' => 'error'
]);
?>

关于php - 如何更改错误类(yii2 形式),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33462068/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com