yiisoft / yii2-bootstrap

Yii 2 Bootstrap 3 Extension
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
185 stars 193 forks source link

yii\bootstrap\Html::error() and help-block-error class #148

Closed yii-bot closed 6 years ago

yii-bot commented 8 years ago

This issue has originally been reported by @koxu1996 at https://github.com/yiisoft/yii2/issues/12010. Moved here by @samdark.


What steps will reproduce the problem?

use yii\bootstrap\Html::error()
...
$form = ActiveForm::begin();
    echo $form->field($model, 'fieldname')->begin();
        echo Html::activeLabel($model,'fieldname');
        echo Html::activeTextInput($model, 'fieldname');
        echo Html::error($model,'fieldname');
    echo $form->field($model, 'fieldname')->end();
ActiveForm::end();
public function rules()
{
    return [
        [['fieldname'], 'required']
    ]
}

What is the expected result?

Working client-side validation

What do you get instead?

Client-side validation does not work, because yii\bootstrap\Html::error() generate p block without needed help-block-error class. The same with label(), which does not add control-label class. It took me a lot of time to figure out that I should add it, to get it working. I know I can do it easily, but why this is not out of the box?

Additional info

Q A
Yii version 2.0.9
PHP version 5.5.9-1ubuntu4.17
Operating system Ubuntu 14.04
klimov-paul commented 6 years ago

Resolved by commit a8c0b23e0c7a776a37a835834a419a031878fc7b