ActiveForm创建表单,如何只生成表单不生成div标签 [ 2.0 版本 ]
$form = ActiveForm::begin([
'id' => 'login-form',
'options' => ['class' => 'form-vertical'],
'fieldConfig' => [
'template' => "{input}\n<div class=\"col-lg-8\">{error}</div>",
//'labelOptions' => ['class' => 'col-lg-1 control-label'],
],
]);
$form->field($model, 'username')->passwordInput(['username']);
生成的表单如下:
<div class="form-group field-loginform-username required">
<input type="password" 0="username" name="LoginForm[username]" class="form-control" id="loginform-username">
<div class="col-lg-8"><p class="help-block help-block-error"></p></div>
</div>
默认会有个 <div class="form-group field-loginform-username required">
这样的div,当我不想要这个div,只要输出个input就行了,否则会导致页面错乱。
请大神指教
共 5 个回答
-
<?php $form = ActiveForm::begin([ 'action' => ['test/getpost'], 'method'=>'post', 'options'=>['class'=>'form form-horizontal'], 'id'=>'form-dict-add', 'fieldConfig'=>[ 'template'=> "{label}\n<div class=\"formControls col-xs-8 col-sm-9\">{input}</div>\n{error}", 'labelOptions'=>['class'=>'form-label col-xs-4 col-sm-2'], 'options'=>['class'=>'row cl'], ] ]); ?>
这么写options去改变外层生成div的class
-
<?php $form = ActiveForm::begin([
'options'=>['enctype'=>'multipart/form-data','class' => 'form-horizontal'], 'fieldConfig' => [ 'template' => "{label}\n<div class=\"col-lg-5\">{input}</div>\n<div class=\"col-lg-3\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-1 control-label'], //修改label的样式 ] ]); ?>
效果如下
吴笛
注册时间:2013-12-24
最后登录:2016-08-03
在线时长:39小时27分
最后登录:2016-08-03
在线时长:39小时27分
- 粉丝5
- 金钱0
- 威望20
- 积分590