3

Running: Laravel 5.3 with Laravel Backpack CRUD 3.1

I am running into situations where I have a Model that I would like to add multiple related (child) records too, using just one CRUD form. Some examples would include adding multiple files... but let's start small. I have found the following posts that have similar topics, but not clear answer on the best way to do this.

Is the best way to use the table Field Type? https://laravel-backpack.readme.io/docs/crud-fields#section-table But, I guess the drawback is not having validation on the child records?

A similar tutorial to this one would be cool: https://backpackforlaravel.com/articles/tutorials/nested-resources-in-backpack-crud

So, an example would be where I have a Journey model and would like to add multiple Chapters to the Journey directly on the same Journey CRUD form.

Let me know if this question makes sense... and any suggestions/advice you can share.

JFK
  • 33
  • 4

1 Answers1

2

Backpack doesn't support adding more entities in one form - every such form is very different.

My recommendation would be to edit the EntityCrudController::store() and EntityCrudController::update() methods, to check for the values of the "table" field and add/update/remove connected entries.

tabacitu
  • 6,047
  • 1
  • 23
  • 37
  • at year 2021, is no a solution for this common use case? We cannot use table because it's using only text fields and we need a fw select2. Our use case is an 'event' havig child 'relations'. – realtebo Mar 17 '21 at 11:54
  • 1
    This question and answer are from 2017. I think you should take a look at [our `repeatable` field type](https://backpackforlaravel.com/docs/4.1/crud-fields#repeatable-1) - I think it's exactly what you're looking for – tabacitu Mar 18 '21 at 12:25
  • 1
    thanks, but no. In a lot of circumstances we need to edit related 1->N rows without using a simple json attribute. – realtebo Mar 19 '21 at 13:19