如何为Yii字段指定自定义CSS类?

I tried

  <?= $form->field($model, 'q', array('class' => 'form-control input-lg')) ?>

and

  <?= $form->field($model, 'q', ['class' => 'form-control input-lg']) ?>

It gives the following error

ReflectionException Class form-control input-lg does not exist

The docs were no help and didn't give examples.

http://www.yiiframework.com/doc-2.0/yii-widgets-activeform.html#field()-detail

The guide even shows the above format for a button!

http://www.yiiframework.com/doc-2.0/guide-input-forms.html

Try this

<?= $form->field($model, 'q')->textInput(['class' => 'form-control input-lg']); ?>

Edit: As suggested by @soju

<?= $form->field($model, 'q', ['inputOptions' => ['class' => 'form-control input-lg']])

When you don't specify any method for field it automatically treats it as a textInput by default.

Use:

<?= $form->field($model, 'q')->textInput(['class' => 'form-control input-lg']); ?>