Including list view of relationship entity on update page

后端 未结 2 919
青春惊慌失措
青春惊慌失措 2021-01-07 17:05

I am trying to extend an update view to include a list view of some related items below the edit form.

I have two models, Publishers and Volumes, which have a many t

2条回答
  •  天命终不由人
    2021-01-07 17:42

    As @tabacitu mentioned, Backpack doesn't currently have an built in solution for this. That said, this could maybe work for you:

    This would allow you to use all functionality of the nested list view including interacting with the entities without conflicting at all with the parent

    Step 1, Build your normal CRUDs

    • Build out two normal CRUDs, one for Publishers, and one for Volumes

    Step 2, Make a frameless layout

    • copy vendor/backpack/base/layout.blade.php
    • name it frameless-layout.blade.php
    • remove @include('backpack::inc.main_header') and @include('backpack::inc.sidebar')

    Step 3, Make a custom list view

    • copy vendor/backpack/crud/list.blade.php
    • name it sub-list.blade.php
    • change the top line to @extends('backpack::frameless-layout')

    Step 4, Make a custom field

    • Create a custom form field that contains an iFrame
    • Inside your custom field template, have it set the url of the iFrame to the "list" url of the related resource
    • You'd also need to utilize List Filters and a method for setting them dynamically so that the sub-list shows only the records related to the parent

    Step 5, Configure and use the field

    • In your crud controllers, use the addField to add the the configuration for the new field and its related model

提交回复
热议问题