在 Laravel Form Collective HTML select 中添加样式并禁用单个选项

Add styles and disable individual options in a Laravel Form Collective HTML select

我正在尝试使用 Laravel Collective 的 HTML select:

复制此 HTML 表格

<option value="Vehicles"style="background-color:#E9E9E9;font-weight:bold;" disabled="disabled"> - Vehicles - </option>

这是我的 blade:

{{ Form::select('subcategories', $subcategories, null, ['class'=>'form-control']) }}

此处的文档相当有限: https://laravelcollective.com/docs/5.3/html#drop-down-lists 并且不表示是否可以使用个别样式或是否可以禁用。

Whosebug 上也有类似的问题

Using Laravel Form class to add the 'disabled' attribute

这里讨论的是'disabled',但好像是针对整个select。评论区有人问个别项目,但没有明确答复。

这可能吗?

这将禁用整个 select 元素:

{!! Form::select('subcategories', $subcategories, null, ['disabled' => true, 'class' => 'form-control']) !!}

更新

您想禁用某些选项。不可能,因为select() method doesn't have such functionality

你能做的就是create macro like this one