4
這就是我添加帶有文本字段的圖標的方式。還添加了生成輸出的圖像。 我不想使用Krajee Yii Extensions。所以我開始閱讀文檔。如何在yii2 alpha中預先添加/附加bootstrap3圖標到活動窗體
$form = \yii\widgets\ActiveForm::begin([
'id' => 'form-id',
'options' => ['class' => 'form-horizontal'],
'enableClientValidation'=> false,
'enableAjaxValidation'=> true,
'validateOnSubmit' => true,
'validateOnChange' => true,
'validateOnType' => true,
'action' => 'youraction',
'validationUrl' => 'yourvalidation'
]);
echo $form->field($model, 'fieldname')->begin();
echo Html::activeLabel($model,'fieldname', ["class"=>"col-sm-3 control-label"]); ?>
<div class="input-group col-sm-4 ">
<span class="input-group-addon">
<span class="glyphicon glyphicon-subtitles"></span>
</span>
<?php echo Html::activeTextInput($model, 'fieldname', [
'class'=>'form-control',
'autocomplete'=>'off'
]
); ?>
</div>
<?php echo Html::error($model,'origin', ['class' => 'help-block']);
echo $form->field($model, 'origin')->end();
\yii\widgets\ActiveForm::end();
請不要使用「引導」標籤,使用「Twitter的自舉」,因爲這意味着別的 –