Needs review
Project:
DER Extra
Version:
1.0.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
25 Nov 2014 at 17:44 UTC
Updated:
15 Jun 2026 at 11:16 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jibranThanks for creating a feature request I am working on this same feature in #2346273: Allow user to select bundles per entity type on field settings page. I think it is really close now. After fixing #2346273 I am planning to work on autocomplete route to use the same settings selected in field settings form. So #2346273 will fix this issue but let's keep it open for autocomplete route update. We can postpone this on a #2346273 and re-title this.
Comment #2
dave reidYeah, just to clarify, the problem is I don't want to limit selection to certain bundles, but just in the widget only, not the field settings.
Comment #3
jibranAs I suggested here #2423093-5: Allow multiple target entity types in the 'entity_autocomplete' Form API element we can implement hierarchical select type widget to select bundles. We can add a widget option to turn this setting on. We'll only show the bundles selected in field settings. Let me complete #2411981: Fixes after generic 'entity_autocomplete' Form API element first then I'll have a look at it.
Comment #4
jibranThis is totally possible if we change
traget_bundlesinhandler_settingsbut selection handler settings are stored in\Drupal::keyValue('entity_autocomplete')before the creation of autocomplete link. One way to fix it is to add a target bundle select and trigger AJAX onchange to change the selection settings. We should do it in a new widget.Comment #5
rp7 commentedI was working on something similar for a project of mine, only found this issue afterwards. Patch attached adds a new widget Autocomplete (per bundle) for Dynamic Entity Reference fields.
Seems to work pretty well, improvements/reviews always welcome.
Comment #6
rp7 commentedRemoved a tiny project-specific left-over.
Comment #7
jibranNice one. Can you please share some screenshots? Should we add it to https://www.drupal.org/sandbox/jibran/2932751?
Instead of doing this can we create target type dependent bundle select(s) using states?
Comment #8
rp7 commentedA few more bugs I found in my previous patch:
Comment #9
rp7 commentedBundle default value still not always correct, hopefully finally fixed now. Sorry for the spam!
Comment #10
rp7 commented@jibran
For the screenshots:
The default autocomplete widget:

The per bundle autocomplete wiget:

The above screenshots were taken from an installation with the following entity types & bundles:
Comment #11
rp7 commentedComment #12
rp7 commented@jibran
Honestly no idea what you mean with this. Can you elaborate a little bit more? Perhaps give a raw code example? Not sure if I can make more time available for this the next few days/weeks, but I can try.
Comment #13
wim leersI think @jibran means:
instead of HEAD's
or your patch's
(That's also what he was alluding to in #3.)
Comment #14
rp7 commentedI have a (new) use case where I need to have an AJAX callback triggered by a change event on the target_id element. I noticed an issue that - when replacing the completely rendered field through AJAX - the autocomplete gave suggestions for the wrong bundle. Fixed it in the patch attached.
FYI, we have been using this widget for about 2 years now on a decently sized production site. It's used in 10+ content types, by 30+ editors. No issues so far. Wondering how we should proceed with this (knowing this is - obviously - not the finished product yet):
Comment #15
jibranLet's do this. We can promote this to a full project as well.
I still think we should still consider exploring the following option:
Comment #16
jibranComment #17
p-neyens commentedMy patch contains the fix for the incorrect namespace path.
Comment #18
rp7 commentedUpdated patch because the schema info for the new widget was missing.
PS: I also added a patch based on #14 (where the widget was still part of the dynamic_entity_reference module, and not the der_extra module). This because the der_extra module apparently requires the Chosen module - something that isn't needed for this widget & I don't want to install on my project. IMO we'll have to address this as well before this is committed to the der_extra module.
Comment #19
rp7 commentedComment #20
rp7 commentedUpdated patch so that the first select option is now selected by default
Comment #22
gugalamaciek commentedApply changes related to: https://www.drupal.org/project/dynamic_entity_reference/issues/3600917