@gabe
2016-10-03T17:32:21.000000Z
字数 589
阅读 1855
Yii2
form
在yii2中使用gii生成是表彰格式是完全垂直的,如果想需要label和input平等的,可以这样修改代码
use yii\helpers\Html;
use yii\widgets\ActiveForm;
$form = ActiveForm::begin([
'id' => 'login-form',
'options' => [
'class' => 'form-horizontal',
],
'fieldConfig' => [
'template' => '{label}<div class="col-lg-6">{input}</div>{hint}{error}',
'labelOptions' => [
'class' => 'control-label col-lg-2',
],
]
]) ?>
<?= $form->field($model, 'username') ?>
<?= $form->field($model, 'password')->passwordInput() ?>
<div class="form-group">
<div class="col-lg-offset-1 col-lg-11">
<?= Html::submitButton('Login', ['class' => 'btn btn-primary']) ?>
</div>
</div>
<?php ActiveForm::end() ?>