Generating labels and inputs separately [SOLVED]

Hello. I have form, which is hard to generate with field(), because layout contains a lot of html between label, input and error. Instead of fighting with template option, in Yii1 I could use CHtml::activeTextField, CHtml::activeLabel and form was normally working with validation. How I can do it in Yii2?

Yii2 Active fields are wrapped in bootstrap. Perhaps you can use the activeform itself and get the desired layout.

activeLabel(), activeTextInput() and likes are implemented in yii\helpers\Html. They are the equivalents of CHtml::activeXXXX in Yii 1.1.

Please refer to the API documentation of yii\helpers\Html.

http://www.yiiframework.com/doc-2.0/yii-helpers-html.html

The extended yii\bootstrap\(Base)Html also supports them just with the same name and the signatures.

Referring to this: https://github.com/yiisoft/yii2/issues/3237 client-side validation will not work and this is by design. Maybe there is another way?

Edit

I found solution here: http://stackoverflow.com/questions/24698403/how-to-display-only-label-and-error-for-activefield-in-yii2


echo $form->field($model, 'fieldname')->begin();

        echo Html::activeLabel($model,'fieldname');

        echo Html::activeTextInput($model, 'fieldname');

        echo Html::error($model,'fieldname', ['class' => 'help-block']);

echo $form->field($model, 'fieldname')->end();

I think this is important and should be mentioned in docs.