问题描述:

I'm trying to add a class for a TextField like this one:

<div class="form-group-lg">

<?= $form->field($model, 'email'); ?>

</div>

Output:

And that would be something like this?(the label will be inside the TextField).i mean, can we use it like below codes?

Example:

I need something like this:

<div class="form-group label-floating">

<label class="control-label" for="focusedInput1">Write something to make the label float</label>

<input class="form-control" id="focusedInput1" type="text">

</div>

http://fezvrasta.github.io/bootstrap-material-design/bootstrap-elements.html

Forms section-first one.

So, the question is,

How can i add a class to this item with above codes on Yii2 ActiveForm?

网友答案:

You need to use fieldConfig Propertie in ActiveForm.

Like as

<?php $form = ActiveForm::begin([
    'id' => 'active-form',
    'fieldConfig' => [
        'template' => "<div class=\"form-group label-floating\">{label}{input}{error}</div>",
    ],
]); ?>

For more info read Docs

相关阅读:
Top