【发布时间】:2014-04-14 07:37:06
【问题描述】:
我想用 optgroups 创建一个选择字段
$spec = DB::table('agentspec')->orderBy('category', 'desc')->get();
表格有三列
category, spec, agentdesc
optgroup 标签是“category”,选择值是“spec”
这是我尝试过的 出错 试图获取非对象的属性
@foreach($spec as $spec)
@if ($spec->category == 'Agent')
<optgroup label="Agent">
@foreach($spec as $spec)
<option value="{{ $spec->spec}}">{{ $spec->spec }}{{ $spec->agentdesc }}</option>
@endforeach
</optgroup>
@endif
@endforeach
【问题讨论】: