Peanut
Peanut

Reputation: 3295

Laravel nest view inside nested view

Ok so I have been looking around and can NOT find the answer to this. However, I need to nest a view inside of another view.

I have a $layout that is using the default.layout blade file I have. Well that layout file contains a section:

@yield('content')

So in my admin panel, I have something like this:

$this->layout->nest('content', 'admin.items.index', $this->data);

HOWEVER, INSIDE of my index.blade.php file, I have a @yield('form'). Then I have a form.blade.php file under the admin/items directory.

@section('form')
FORM HERE
@endsection

Yes, nesting a form is not necessary, BUT it is with what I'm doing. So how would I nest that view inside the index view that is nested inside the content area?

I tried this which might be a huge fail, but it won't work:

$content = $this->layout->nest('content', 'admin.items.index', $this->data);
$content->nest('form', 'admin.items.form');

Upvotes: 2

Views: 3142

Answers (1)

XoneFobic
XoneFobic

Reputation: 126

give this a try:

$this->layout->content = View::make('admin.items.index')
                             ->with('data', $this->data)
                             ->nest('form', 'admin.items.form');

Now you can call whatever is in $this->data through the variable $data and it should load the form just fine.

Upvotes: 5

Related Questions