yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

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

Closed koxu1996 closed 8 years ago

koxu1996 commented 8 years ago

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
yii-bot commented 8 years ago

Issue moved to https://github.com/yiisoft/yii2-bootstrap/issues/148