How To Add Css Class To Field In A Form

Hello guys!

I’m using an extension for Yii 2 and I need to use this code:

$form->field($model, ‘hashtag’)->widget(…);

But I want to add a css class in a text field.

How can I do this?

hi, have not used Yii 2.0 yet but, have you tried a similar code like the following:




$form->textField($model,'columnName',array('class'=>'className'));



Method field() in docs.

So yes, you may pass it as the third parameter or configure $fieldConfig beforehand.