Yii2 active form inputiga css classlarini qo'shish

+1 ovoz
63 marta ko‘rilgan
so‘radi 26 avgust alfraganus (515 bal)
Assalomu Aleykum, quyidagi html formlar ichidagi classlarini, yii2 ning active form inputiga kochirishga doim qiynalaman, iltimos, kimdir batafsil o'rgatib qo'ya oladimi yoki shuni o'rgatadigon biror bir maqola bormi, ingliz tilidami yoki rus tilidami, shu narsani ancahdan beri o'rgana olmayapman. masalan hozirda menga shu kerek:

<div class="form-group">
                            <label for="name" class="cols-sm-2 control-label">Your Name</label>
                            <div class="cols-sm-10">
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="fa fa-user fa" aria-hidden="true"></i></span>
                                    <input type="text" class="form-control" name="name" id="name"  placeholder="Enter your Name"/>
                                </div>
                            </div>
                        </div>

endi shu klasslarini bu inputga kochirish kerek:

<?= $form->field($model, 'username') ?>

2 Javoblar

+1 ovoz
javob berdi 09 sentabr Farhodjon (1,018 bal)
tanlangan 09 sentabr alfraganus
 
Eng yaxshi javob
<?= $form->field($model, 'username', [

'template' => '{label}<div class="col-sm-10"><div class="input-group"><span class="input-group-addon"><i class="fa fa-user"></i></span>{input}</div></div>',

'labelOptions' => ['class' => 'col-sm-2 control-label'], //Label uchun optionla. Ex: tag, class, id...

'options' => [] //O'rab turgan div uchun optionlar. Ex: tag, class, id... lani bersa boladi

])->textInput(['placeholder' => 'Enter your name']) ?>
izoh qoldirdi 09 sentabr alfraganus (515 bal)
huddi shunga o'xshash izohli javob kutgandim, Rahmat Farhodjon aka
–2 ovoz
javob berdi 28 avgust Specialist001 (150 bal)
tahrirlandi 28 avgust Specialist001

<?php
use yii\widgets\ActiveForm;

$form = ActiveForm::begin();

echo $form->field($model, 'userName');
echo Html::submitButton('Send', ['class'=>'btn btn-primary']);
ActiveForm::end();
?>
izoh qoldirdi 28 avgust alfraganus (515 bal)
bu javob emasku, qani klasslar form ichida

Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.

Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin.

Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

Telegram kanal YordamUzRss

...