The Best Way to Adjust Input Width

What is the best way to adjust the width of input field (textfied, dropdown, etc.)? Until now I can only do:




$form->field($model, 'first_name', [

   'template'=>'<div class="row"><div class="col-lg-4">{label}{input}{error}</div></div>'

])->textInput()



which looks cumbersome, especially when there are a lot of fields in the form. If we tried to set the style:


$form->field($model, 'first_name')->textInput(['style'=>'width: 30%'])

will the responsive functionality lost? I wonder if there is a way to set it like Yii 1.1:


$form->textField($model, 'name', array('size'=>60))

You can still set size via third argument but in order to stay responsive you need to follow what bootstrap proposes.

I have tried it before:


$form->field($model, 'first_name')->textInput(['size'=>5])

and it didn’t change the width of textfield (like mentioned in this issue). Is there a more efficient way to adjust field width than setting template property?

No if you’re using bootstrap css.

Thanks for clarifying it. +1 :)