【发布时间】:2015-07-16 04:10:34
【问题描述】:
我的刀片文件中有这个:
<select class="form-control" name="category" id="category">
@foreach ($category as $h)
@if ({{$h->id}} == {{$directory->category}})
<option value="{{$h->id}}" selected>{{$h->name}}</option>
@else
<option value="{{$h->id}}">{{$h->name}}</option>
@endif
@endforeach
</select>
和控制器:
$directory= Directory::find($id);
$category = StoreCategory::all();
return view('edit')->with('category', $category)->with('directory', $directory);
打开编辑时,我收到“语法错误,意外'
尝试删除 if-else 条件,它工作正常。
【问题讨论】:
-
意外
-
这一行:@if ({{$h->id}} == {{$directory->category}})