我正在尝试为此类TextField
添加一个类:
<div class="form-group-lg">
<?= $form->field($model, 'email'); ?>
</div>
输出:
那会是这样的吗?(标签会在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上使用上述代码向此项添加一个类?
答案 0 :(得分:1)
您需要在fieldConfig
中使用ActiveForm
个属性。
喜欢
<?php $form = ActiveForm::begin([
'id' => 'active-form',
'fieldConfig' => [
'template' => "<div class=\"form-group label-floating\">{label}{input}{error}</div>",
],
]); ?>
有关详细信息,请参阅Docs