如何在Yii2上使用Material Bootstrap设计类为ActiveForm项目定制/添加类

时间:2015-12-24 12:07:22

标签: php twitter-bootstrap yii2 yii2-advanced-app bootstrap-material-design

我正在尝试为此类TextField添加一个类:

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

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

                </div>

输出:

enter image description here

那会是这样的吗?(标签会在TextField内)。我的意思是,我们可以像下面的代码一样使用它吗?

示例:

我需要这样的东西:

<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

  

表格部分 - 第一部分。

所以,问题是,

如何在Yii2 ActiveForm上使用上述代码向此项添加一个类?

1 个答案:

答案 0 :(得分:1)

您需要在fieldConfig中使用ActiveForm个属性。

喜欢

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

有关详细信息,请参阅Docs