This is how i added the icon with text field. Also added the image of generated output. I don't want to use Krajee Yii Extensions. So i started to read the documentation.
$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();
Is this a question or you are showing us how you did it?
You should also be able to do something like:
<?= $form->field($model, 'fieldname', ['template' => '
<div class="col-sm-2">{label}</div>\n
<div class="col-sm-10">
<div class="input-group col-sm-4 ">
<span class="input-group-addon">
<span class="glyphicon glyphicon-subtitles"></span>
</span>
{input}
</div>
{error}{hint}
</div>'])->textInput(['data-default' => '']) ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With