0

I'm building a Laravel app that uses SBAdmin 2. The SBAdmin2 has a collapsable panel of which an example is below (as provided by 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 'body' needs to be passed to the widget. The example above contains just a string, but I need to pass an HTML table.

@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))

Am getting all kinds of syntax errors, so looking for a way to pass an html table to the body of the collapsible panel.

wiwa1978
  • 2,317
  • 3
  • 31
  • 67

1 Answers1

0

Just to confirm make sure data is being passed into the panel_lot_panel_body section by entering basic text @section('panel_lot_panel_body', 'Hello world') and once you've confirmed that you should set the $body variable in the controller (not the Blade template). So in your controller before returning the view so:

$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'));
Josh LaMar
  • 199
  • 3
  • 8
  • I'm sure that text is being passed to the body. I don't like to put HTML code in a controller though so was hoping for another possibility. – wiwa1978 Jun 13 '16 at 15:30