我正在构建一个使用SBAdmin 2的Laravel应用。 SBAdmin2有一个可折叠的面板,下面是一个例子(由SBAdmin2提供):
<div class="col-sm-12">
@section ('collapsible_panel_title', 'Collapsible Panel Group')
@section ('collapsible_panel_body')
@include('widgets.collapse', array('id'=>'1', 'class'=>'primary', 'header'=> 'This is a header', 'body'=>'Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo.','collapseIn'=>true))
@include('widgets.panel', array('header'=>true, 'as'=>'collapsible'))
</div>
A&#39;身体&#39;需要传递给小部件。上面的例子只包含一个字符串,但我需要传递一个HTML表。
@section ('panel_lot_panel_body')
@if(
$body = "<table class="table table-striped table-bordered table-list">
<thead>
<tr>
...
</tr>
</thead>
<tbody>
@foreach( $all_lots as $lot )
<tr>
...
</tr>
@endforeach
</tbody>
</table>")
@endif
@endsection
@include('widgets.panel', array('header'=>true, 'as'=>'panel_lot_panel'))
@include('widgets.collapse', array('id'=>'1', 'class'=>'primary', 'header'=> 'This is a header', 'body'=>{{$body}},'collapseIn'=>true))
我遇到了各种语法错误,因此正在寻找一种方法将html表传递给可折叠面板的主体。
答案 0 :(得分:0)
通过输入基本文本panel_lot_panel_body
并确认您应在控制器中设置@section('panel_lot_panel_body', 'Hello world')
变量后,确认确保数据已传入$body
部分不是刀片模板)。因此在返回视图之前在控制器中:
$body = "";
$body .= '<table class="table table-striped table-bordered table-list">
<thead>
<tr>
...
</tr>
</thead>
<tbody>';
foreach( $all_lots as $lot )
$body .= "
<tr>
...
</tr>";
endforeach
$body .= '
</tbody>
</table>';
return view('your.blade.template', compact('body', 'anyothervariables'));