Laravel-Backpack / community-forum

A workspace to discuss improvement and feature ideas, before they're actually implemented.
28 stars 0 forks source link

Layout field / page field / block editor field / create content based on multiple different models #240

Open UnbekanntesPferd opened 1 year ago

UnbekanntesPferd commented 1 year ago

Feature Request

What's the feature you think Backpack should have?

For content creation a nice feature I saw in Drupal's paragraphs module, was to have something similar to Backpack's repeatable but for different model types. So you can e.g. create the content of a news article by adding text, image gallery, text again, linked articles, text again, ... where each of these types can be sorted/deleted/... I couldn't find a way to implement this already with current backpack fields.

Have you already implemented a prototype solution, for your own project?

Drupal paragraphs: https://www.youtube.com/watch?v=Fy9s01T30uo

Do you see this as a core feature or an add-on?

Not sure.

welcome[bot] commented 1 year ago

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication channels:

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

-- Justin Case The Backpack Robot

pxpm commented 1 year ago

Hello @UnbekanntesPferd

Thanks for the suggestion. Isn't that (or something similar) what we are already doing with repeatable by creating relationships using the repeatable subfields ?

Please have a look at https://backpackforlaravel.com/docs/5.x/crud-fields#save-additional-data-to-pivot-table and also https://backpackforlaravel.com/docs/5.x/crud-fields#create-related-entries-in-a-modal-using-the-inlinecreate-operati

Let me know if that is what your are looking for.

Cheers

UnbekanntesPferd commented 1 year ago

Hi @pxpm ,

thanks for your reply. It's not exactly what my suggestion was.

I was thinking about a relationship for multiple different models. So instead of having one "+New Item"-button, it would need a dropdown and an add-button, to not "only" be able to add people (like in the example), but also to e.g. animals, trees, ... that are completely different models with different field types. Or maybe I'm not fully understanding the example and it already offers that?

pxpm commented 1 year ago

@UnbekanntesPferd Maybe it's easier to understand with a concrete example, some use case where that would be helpfull.

Imagine that I have a City model, that has Persons, Trees and BelongsTo a country (country_id).

In the City create, I would be using the relationship (hasMany/BelongsToMany) Persons/trees with subfields, and in the BelongsTo country, I would use inline create (show the + New Item).

That will allow you to create Persons (BelongsToMany also supports InlineCreate), Trees and Persons.

Maybe check your demo repository https://demo.backpackforlaravel.com and our demo code: https://github.com/Laravel-Backpack/demo

UnbekanntesPferd commented 1 year ago

@pxpm Sorry, seems like I'm failing in explaining it :-).

Here is an example of how it could look like. Maybe this makes it easier to understand: SCR-20221218-kpc

pxpm commented 1 year ago

Ohh, I think I got the idea now ... thanks for the screenshot it really helped. 👍

We don't have nothing like that in core. You can do it with 3 separate fields, 1 for each entity but that's it, all together it's not possible at the moment.

Remember that this "fields" are just html entities, you can start a copy of a custom repeatable php artisan backpack:field custom_repeatable --from=repeatable and customize it to have the interface you desire, but almost 100% it would also need to override the saving process as Backpack is not aware that the same field could submit 3 different entities.

I will be moving this to the ideas repository, it's from there that we, from time to time, see what requests have traction (people show desire to have it), and we build the new features based on what users ask.

Sorry if I can't help much more. Wish you the best 🎅

UnbekanntesPferd commented 1 year ago

Thank you very much! I will play a bit with the (custom) repeatables, maybe I'll find some solution :)

All the best to you!

tabacitu commented 1 year ago

Note - we did create a package a few years ago, to help create pages easily using "blocks". Each block can then hold different types of fields:

113820544-856daf00-9783-11eb-8a7d-429b54ea3f93

It's no longer working on the current version of Backpack, it was Bootstrap 3 and the JS library we used is no longer maintained. But... yeah... the idea... is this what you meant @UnbekanntesPferd ?

UnbekanntesPferd commented 1 year ago

@tabacitu Yes, this looks exactly like what I was looking for! Maybe you can add it to your (probably very long) list of feature requests ;-)