Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
I have a use case with an entity type with many bundles that can be referenced, but based on the context of how the form is loaded, the entity bundle we want to reference is known. Therefore, I'd like to default to that bundle and have the form open.
Proposed resolution
I've attached a patch that is a simple refactor to InlineEntityFormSimple which makes my use case super easy to implement in custom code. However we could consider implementing this widget directly in IEF if there is interest
Remaining tasks
Review.
Comment | File | Size | Author |
---|---|---|---|
#2 | ief-widget.png | 50.4 KB | benjy |
#2 | 2898030-2.patch | 1.14 KB | benjy |
|
Comments
Comment #2
benjy CreditAttribution: benjy at Unearthed commentedAttached is the patch that simply allows me to override the bundle in my custom widget.
Here's an idea of what my custom widget looks like in case that would be worthwhile contributing back?
Comment #3
darvanenI see no reason not to refactor this piece of code and the patch applies cleanly.
Comment #5
bojanz CreditAttribution: bojanz at Centarro commentedNo reason not to do this. Cleaned up getBundle() a bit to get rid of the ternary. Thanks!
As for the custom widget itself, I don't know how that would work inside IEF itself, but we can discuss in a followup.
Comment #7
joachim CreditAttribution: joachim as a volunteer commentedPlease don't blindly take the commit message d.org offers!
> Issue #2898030 by benjy: Provide a "default bundle" widget
That does not describe at all what was changed here!