EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

Add embedded relations

Open lukasluecke opened this issue 5 years ago • 16 comments

#3352

2020-07-13 17 17 03

// There needs to be a CrudController handling the target entity, as we display the corresponding INDEX view here.
EmbedField::new('associationName');

It supports most of the functionality, including async initial load, sort, pagination, search and actions (with a custom referrer that redirects you straight back to the embed field).

Currently the "reverse" relation field is automatically removed, if it was part of the target index view (because all values would be the current detail view entity).

lukasluecke avatar Jul 13 '20 15:07 lukasluecke

I would like to add a way to further customize the view (e.g. change columns, different default sort, page size), but all customization options should be part of the EmbedField options, and not the target CrudController. This is currently not easily possible, but I got a solution almost ready šŸ™‚

Edit Waiting on #3550 (see #3551 for an example on the usage, which is quite similar to this)

lukasluecke avatar Jul 13 '20 15:07 lukasluecke

Filters are not yet working correctly, their code is even more complicated to make "reusable". I might end up just having to extract all these "inline" scripts to proper functions that get called in any view where they are required, but that will be a bigger change than what I originally intended (and I might do that separately, before finishing up this PR).

Edit I got the filters working with a single embed on the page - will try to make it a bit more flexible next..

lukasluecke avatar Jul 13 '20 16:07 lukasluecke

Should we add an item create button? (Action::NEW)

seb-jean avatar Jul 14 '20 19:07 seb-jean

@seb-jean Iā€˜m not sure yet how exactly I want to handle Actions in general here - maybe something like #3519, and by default render the actions defined for the index view (which in most cases is NEW).

My end goal is a kind of fully integrated experience, which probably will involve AJAX modals for create (and possibly edit), amongst other things - but I will try to get the basic functionality in before that šŸ™‚

lukasluecke avatar Jul 14 '20 19:07 lukasluecke

Okay, great :). I wish you good luck @lukasluecke.

seb-jean avatar Jul 14 '20 20:07 seb-jean

Can this pr be merged into the master?

WeTurkstra avatar Sep 11 '20 12:09 WeTurkstra

I hope this feature will be merged soon šŸ’Æ

ghost avatar Sep 24 '20 10:09 ghost

Wow this feature is exactly what i want :heart_eyes:. Hope it will be merged soon :rocket:.

sharkFace146 avatar Nov 13 '20 14:11 sharkFace146

Thanks for this very useful feature ! Hope it will be merged soon ! I've tested it and I've detected 2 issues :

  • Filter button doesn't work. It's open a new page with the filters fields inside
  • BooleanField that appears in table, cannot be updated (enable or disable). It seems to miss an ajax action to update the entity.

bfavrel avatar Nov 16 '20 19:11 bfavrel

Thanks for your feedback and contribution. I'm currently very busy in another project which does not use EasyAdmin, but hope that I can find some time to finish this PR and some others around christmas time šŸ¤ž

If anyone else wants to pick this up in the meantime feel free to take this over in a new PR as well šŸ™‚

lukasluecke avatar Nov 17 '20 11:11 lukasluecke

Hmm patch needs reroll for EA 3.2 it seems.

finnef avatar Jan 06 '21 14:01 finnef

I would like to add a list of this type for a collection, does it work in easyadmin 4?

Mancusoj avatar Oct 12 '22 13:10 Mancusoj

does it work in easyadmin 4? this is great

wontroba666 avatar Feb 17 '23 10:02 wontroba666

Can this please be implemented? To provide you with a use case for this it's when you need to display a complex entity with one to many relationships in a tab.

Say a Subscription being the primary entity and so you create a tab that has Members (OneToMany). The usecase here is that we're able to display the OneToMany relationship as a paginated and filterable table.

Some subscription records for example have 1000s of records and doing CollectionField::new('members') simple does not work due to the volume of fields it has to display.

AriesXIX avatar Dec 19 '23 13:12 AriesXIX

I'd be willing to invest into this and port this for EA 4 but I have concerns about the acceptance of PRs in general atm. Would that change get accepted or would it be better to create a bundle containing this feature?

msphn avatar Feb 21 '24 14:02 msphn

Are there any news on this topic?

NicoHaase avatar Mar 08 '24 14:03 NicoHaase

I can confirm that this one does not work on EA4 and needs updates quite a bit. I've adapted for my project for some of the functionality to work, but there have been major changes in how the system works so the grid needs to be split into blocks and probably work via horizontal reuse instead of pure inheritance or just need to maintain 2 grid templates - one regular and one for embedded. This needs buy-in from stakeholders, because while not too big, still a sizeable addition to the amount of code to maintain. @javiereguiluz and please tag whoever else needs to be in the loop - is this something that would be accepted? Or should I just maintain my own patch and not bother submitting upstream?

psihius avatar Jul 15 '24 06:07 psihius

I've made a new PR because changes to this for 4.x are extensive and I had to redo some things, there's a lot more work to be done, so I do not see a point keeping this one open any more. 4.x series has a lot more complicated interactions and way it is doing things.

psihius avatar Jul 25 '24 10:07 psihius

Let's close this in favor of #6384 where @psihius is trying to implement this feature in the 4.x branch šŸ’Ŗ

javiereguiluz avatar Jul 25 '24 18:07 javiereguiluz