dongque6377 2013-04-03 17:17
浏览 25
已采纳

在嵌套视图里面的Laravel巢视图

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');
  • 写回答

1条回答 默认 最新

  • duangang3832 2013-04-03 17:29
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部