LaravelBlade 下拉列表类属性不起作用.

I cannot find any reference to class or assigning attributes to select / drop-down lists in the documentation.

http://www.laravel.com/docs/html#drop-down-lists

try 的示例:

{{ Form::select('product_id', $productList, array('class'=>'form-control')) }}

{{ Form::select('product_id', $productList, $attributes = array('class'=>'form-control')) }}

两者都返回相同的html,但没有class属性:

<select id="product_id" name="product_id">
    ... Option Stuff ...
</select>

推荐答案

{{ Form::select('product_id', $productList, null, array('class' => 'form-control')) }}

The third parameter is the key of the currently selected option. Defaults to null.

Laravel相关问答推荐

Laravel AppServiceProvider 中的代码在通过 DeployHQ 部署时停止 Composer 和构建

Laravel 模型事件:delete() 不会从存储中删除文件

为什么 Laravel 5 会自动更新我的日期字段?

磁盘 [视频] 没有配置的驱动程序

为什么人们将 .env 放入 gitignore?

带有消息...必须返回关系实例的 LogicException.

Laravel 中未加密的 cookie

SQLSTATE [42000]:语法错误或访问冲突:1066 Not unique table/alias on relationship

如何创建具有关系的 Eloquent 模型?

升级到 Laravel 5.2 会使所有会话失效

如何使用外部图像生成 html div 的 screenshot截图?

如何更改默认 Laravel Auth 登录视图

laravel 搜索多个以空格分隔的单词

如何在 laravel 中使用 GROUP_CONCAT

如果 Laravel 中的值不为空,如何验证输入字段

Carbon解析到 ISO8601

Laravel X-CSRF-Token 与 POSTMAN 不匹配

Laravel 中的 isDirty() 是什么意思?

如何使用 Laravel 迁移在 Mysql 列中添加注释

Eloquent的关系 - attach附加(但不保存)到 Has Many