CSS Class to Dropdownlist


I am trying to create my first yii2 application. So I am trying to create a dropdownlist under ActiveForm. Here is the code I am using:

$form = ActiveForm::begin(); 

        echo Html::dropDownList('sexes', null,

        ['M'=>'Male', 'F'=>'Female']);



Please note I am not using model for this controller. The dropdown values will be returned by SqlDataProvider.

But the dropdownlist is appearing without any CSS Class. Shouldn’t every field by default get assigned Boootstrap3 Class?

I’m not sure if this will make your form styled or not but are you using \yii\bootstrap\ActiveForm or \yii\widgets\ActiveForm ?

Hey I am using the following namespaces:

use yii\helpers\Html;

use yii\widgets\ActiveForm;

use kartik\grid\GridView;

Use yii\bootstrap\ActiveForm then.

I tried that… doesn’t change anything

Have you got yii\bootstrap\BootstrapAsset included?

Thanks its working fine now.