dongrouli2667 2015-03-12 19:36
浏览 60
已采纳

如何为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

  • 写回答

2条回答 默认 最新

  • duanpao4522 2015-03-12 19:45
    关注

    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']])
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部