<?php $form=ActiveForm::begin([
'id'=>'login-form',//基本配置
'action'=>['article/add'],
'method'=>'post',
'options'=>[
'class'=>'login-form',
'enctype'=>'multipart/form-data',
],
'fieldConfig'=>[
'template'=>'{label}<div class="input-icon"><i class="fa fa-user"></i>{input}{error}</div>',
'labelOptions'=>['class'=>"control-label visible-ie8 visible-ie9"],
'options'=>[
'tag'=>'div'
]
]
]);?>
<?php echo $form->field($model,'username')->textInput(['class'=>'form-control placeholder-no-fix','autocomplete'=>'off','placeholder'=>'用户名']);?>
<?php echo $form->field($model,'password')->passwordInput(['class'=>'form-control placeholder-no-fix','autocomplete'=>'off','placeholder'=>'密码']);?>
<?php echo Html::submitButton('登录',['class'=>'btn green pull-right']);?>
<?php ActiveForm::end();?>
use yii\bootstrap\ActiveForm;
$form = ActiveForm::begin(['layout' => 'horizontal']);
// 隐藏form的标签
echo $form->field($model, 'demo', [
'inputOptions' => [
'placeholder' => $model->getAttributeLabel('demo'),
],
])->label(false);
// 内联 radio list
echo $form->field($model, 'demo')->inline()->radioList($items);
//水平模式控制文本框的大小
echo $form->field($model, 'demo', [
'horizontalCssClasses' => [
'wrapper' => 'col-sm-2',
]
]);
// 除了'default(默认)' 布局 你还可以用 'template' 制定特定的布局:
echo $form->field($model, 'demo', [
'template' => '{label} <div class="row"><div class="col-sm-4">{input}{error}{hint}</div></div>'
]);
// 自定义输入框的结构
echo $form->field($model, 'demo', [
'inputTemplate' => '<div class="input-group"><span class="input-group-addon">@</span>{input}</div>',
]);
ActiveForm::end();
文章
总共 0 条评论