Postponed
Project:
Drupal core
Version:
main
Component:
field system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 Jan 2015 at 01:04 UTC
Updated:
22 Apr 2019 at 10:01 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
larowlanswoon
Comment #2
larowlanHard-blocker for #2407505: [meta] Finalize the menu links (and other user-entered paths) system so claiming it as #CriticalADay ;)
Comment #3
pwolanin commentedshould be critical if we are going to use this to execute the plan
Comment #4
larowlanSo stuck the JavaScript and widget in entity_reference module, like the existing Entity reference widgets.
If you want a widget, you need to enable entity-reference module. If you just want the primitive data type, core is enough.
Added some tests.
Lets see how broken this is.
Nice lunchtime task
Comment #6
larowlanComment #7
larowlanComment #8
kim.pepperComment #9
jibranGreat start.
this is same as parent.
Should be DER.
This is not related.
Comment #11
larowlanFixes #9, that test passes locally so no sure what's up there.
Looks like db-updates need to run?
Comment #12
larowlanScreenshot from stark

Comment #14
larowlanComment #16
larowlancan't work the fail out, hoping someone else can
Comment #17
webchickHm. This isn't necessarily a hard-blocker to #2407505: [meta] Finalize the menu links (and other user-entered paths) system, but was originally listed as a possible example of how we'd implement the UI. Before we go down any particular implementation path, IMO we really should do a round brainstorming, mockups, etc. building on the previous thinking on this at #1123662: Participants did not know how to get the path while creating a menu link and #1101600: Users need to be able to select from list when adding menu items to a menu.
Peter, is this the issue you intended that brainstorming to take place? If so, we probably need a new issue that doesn't have a patch and is more of a brainstorming/discussion piece.
Comment #18
dawehnerIMHO DER would give us a basic tool we could use as a initial prototype. Whether its the solution at the end
is not sure, but its something we can use in the transition phase, without have to worry about further UI bits.
Comment #19
dawehnerWow, that is quite some code, but not that different to entity references.
Here is a quick review.
It would be nice to explain why we need to define a custom data reference definition (I guess its because we want to provide a string for each entity type, right?)
Afaik we use it the other way round, much like @param type $var
It would be also nice to explain why we need a custom field item list.
According to #2389335: Deprecate entity.query service and replace with using the entity storage's getQuery() method we should just use the storage to get an entity query.
SO this doesn't work, see : http://3v4l.org/ioZq3
Just in case you want to convert to [] in all new added files.
Can we at least use \Drupal::entityManager()->getstorage->load...
If you can do both, why not name it available_entity_types or something more generoc?
Ideally this properties would be inherited from the DataDynamicReferenceDefinition ... given that it should now these two already, don't it?
It should be EntityTypeInterface::ID_MAX_LENGTH, yes its the same value, but ...
Should we maybe use "here, because"? At least I would do it like that.
We do have now
$entity->getConfigDependencyKey()It would be helpful to describe it quickly what the behaviour is, we attach here. In other words, WHY, do we need some custom JS
Mh, the optionality does not map the signature, ... not sure what we do here.
Sounds for me like a NotFoundHttpException ...
Can we pass the $account from the controller in?
What about name it "entity_reference_dynamic_autocomplete" to be more in sync with the parent?
Nitpick: Just in case you want to, we support trailing commas now. This is just one of possible implementations.
I'm curious what modern JS standards say, should we use classes here or data attributes to attach the behaviour?
Widgets can use DI, can't they?
Comment #20
catch@webchick Menu links are going to need a field type that can reference any entity type. While entity reference is generic, each field definition is tied to a specific type - so you can configure a field storage to reference nodes OR taxonomy terms, but not nodes AND taxonomy terms at the same time.
This is because entity reference stores the entity type in the field configuration and there's no entity type in the schema (see https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Field!Plugin!Fiel...).
With dynamic entity reference the entity type is in the schema, and it allows for entity types to be excluded, but otherwise any entity type on the system is fair game. (http://cgit.drupalcode.org/dynamic_entity_reference/tree/src/Plugin/Fiel...).
So while the specific UI that DER provides isn't a hard blocker (although it's also available now without a lot of work), the field type itself is.
Comment #21
amateescu commentedI'd like to note that this is true only for the current code in D8 HEAD and D7 contrib. The entity reference field in D7 initially provided a 'target_type' schema column with this exact goal in mind (dynamic entity reference), but it didn't work out due to Views integration, something related to views relationships not being able (or maybe invalid SQL) to join multiple entity base tables from a single field table, but I don't remember the exact details.
Comment #22
jibranFor DER I tried to create the views integration in #2321721: Provide a views relationship for each dynamic entity reference field it worked as it turned out views missing some functionality #2378729: JoinPluginBase doesn't allow extra conditions on left table. The patch just need reroll+views config schama once #2378729: JoinPluginBase doesn't allow extra conditions on left table is in.
Comment #23
catchSo I was wondering about whether we should merge the two field types, but #21 and #22 suggest that could be tricky, useful to know!
Not being able to use views for this doesn't feel like a blocker at all - the core use-case only requires basic EntityFieldQuery (find the menu links referencing X entity) and entity loading (load the entity referenced by Y menu link) - so something we could add separately.
Comment #24
jibranForm #19 @dawehner thank you for the review. If a quick review consist of 20 points then I am wondering what would be in depth review look a like. :D. Here are some replies.
DataReferenceDefinitionso I think it also needs a fix.Comment #25
jibranWe can use views with DER. I had a working patch before I found those issues.

For more DER screenshots please see #2331331: Widget for cardinality 1 is missing the field label. Here is the screenshot form seven for both single field and multi value field.
Comment #26
pwolanin commented@webchick - I agree with catch and dawehner that since this matches the exact use case in terms of data model, it doesn't make seems to do a lot of brainstorming. The widget may be pluggable or can be altered if we aren't happy with the autocomplete, but I think that will make sense as a reasonable starting point.
I thought the plan was to get a working implementation (and data model) and then invest in some UX work?
Comment #27
larowlanComment #28
webchickGotcha, thanks all for the clarification. I'll update the issue summary at #2407505: [meta] Finalize the menu links (and other user-entered paths) system accordingly.
Comment #29
larowlantagging for re-roll during office hours today
Comment #30
xjmSo, having read #20 and #21, I'm not sure why we need to add an additional field type to core, rather than building on the functionality of ER. That seems to move us in the wrong direction, IMO.
Comment #31
larowlanProbably worth noting that comment module has entity_id and entity_type in it's schema - which could re-use whatever we come up with here.
Comment #32
amateescu commentedYes, I should have been more explicit myself, sorry :) #21 should read more as: I would prefer if we can bake this functionality into the existing ER field type rather than a separate non-configurable field which has to override quite a bit of assumptions/code from the existing one.
On the other hand, I think I have a viable alternate solution for this entire problem space that I will finish writing soon and post it in the parent meta issue.
Comment #33
larowlanIrc conversation
larowlan
xjm: just to be clear you're proposing we change the schema of ERReferenceItem to add an entity_type column?
xjm
larowlan: that we consider it, at least
larowlan
xjm: ok
xjm: views would be the sticking point
xjm: it would mean dynamic joins I think
xjm: exploring this a bit more, in that world, node_field_data would need three more columns, one for each of the three ER fields?
xjm
uh
dawehner
larowlan: 3?
larowlan
xjm: dawehner uid, revision_uid, node_type
berdir
revision uid is just in the revision table and type is in the base table. but yes, still a lot more columns :)
larowlan
taxonomy would get 2 for vid and pid
dawehner
larowlan: oh you want to also merge the revisions in?
larowlan
comment for comment-type and author
user roles table for the role
xjm
okay so I missed something, why would this mean we need to denormalize everything?
larowlan
I'm playing devils advocate here
xjm
er normalize
wait
larowlan
so either the entity type is in the field config (ER) field or its in a column (DER)? is there another way?
xjm
All I'm saying is it's a huge UX fail to have two things in core that do almost the same thing
larowlan
xjm: wait this is no UI » TRUE
xjm
I wasn't actually thinking about the data model at all and still don't see why we couldn't just join
larowlan
xjm: you cannot use it from field UI
berdir
it's a huge ux fail to have taxonomy term ref and entity ref
dynamic ER and ER is IMHO quite different
larowlan
xjm: so it is limited to single cardinality base fields
xjm
larowlan: but there are screenshots of a UI all over the issue?
I must have failed at reading
larowlan
xjm: the UI is on a base field
xjm: uses a widget just like title
xjm: but no way should it be available from field UI to add new fields - agree 1000%
xjm: if you want that, you need the DER contrib module
xjm: also, the UI should be considered representative (what you get for free) the field is about the data model at this stage, far as I'm aware that is the intent
widgets are widgets
Comment #34
pwolanin commented@xjm, @amateescu - Please let us move forward with DER as a separate field type. Trying to rewrite core entity reference as part of this will mean we are digging ourselves into a deep hole and expanding the scope of this issue from doable in the 2 week timeframe to undoable in a much longer time frame.
Comment #35
pwolanin commentedI'm not seeing that test exception locally.
Berdir tells me #1927648: Allow creation of file entities from binary data via REST requests is related since it would potentially fix the fact that EntityReferenceItemNormalizer doesn't include the entity type, which we'd want for a DER field.
Fixing some of the trivial/doc changes suggested by dawehner
re: #4 - skipping until I see if tests pass
re: #5 - Since it's not a static method, I think we just have to copy the code?
re: #9 - I don't think it can use the parent definition, since it's very much based on the settings.
re: #11 - I think it's ok as is, or I don't understand the suggestion
Comment #37
larowlanThere's a der normalizer in the contrib project if needed
Comment #38
larowlanNote I asked @tstoekler to have a look at this issue in case there's something he can suggest w.r.t. the exception
Comment #39
pwolanin commentedok, let's try splitting up the test modules, since somehow adding the 2 base fields seems to be failing on testbot.
Comment #41
pwolanin commentedOk, something is fragile about altering in the base field, so let's just split out a test entity type where it's actually a normal base field for initial testing.
Comment #42
jibranI think we need DynamicEntityReferenceItem::defaultFieldSettings() here.
Comment #43
jibranFixed #42 and some minor adjustments. Thanks @pwolanin for fighting with test bot to fix the fails.
This should be Valid DynamicReference IMO
Comment #44
jibranFixing #43 in #2405607: Fix DER constraint validation it is not a blocker imo
Comment #45
pwolanin commentedLooks like we still need to wait for #2107243: Decouple entity reference selection plugins from field definitions to uncomment the last part of the test.
Without that the SelectionPluginManager doesn't find what it's looking for since it ends up getting the setting from the itemDefinition rather than the fieldDefinition. Maybe easier to fix the underlying problem?
Comment #46
pwolanin commentedTesting the autocomplete route in the test and by hand - it's broken the same as for the widget posting with no ID present.
Here are some more small fixes from review in #19, plus some more commented-out test code.
Comment #47
pwolanin commentedpostponing due to change of direction on the parent issue
Comment #48
larowlanno longer a blocker
Comment #49
dpiAdding related issue.
Comment #50
dpiIs this still being considered for core? Especially considering parent issue is going with just node entity type for now*
* #2418017: Implement autocomplete UI for the link widget : Resolution
Comment #51
webchickI think it could, but at this point I'd be inclined to mark it a feature and postpone to 8.1.x. Other opinions?
Comment #52
webchickAlso note that there's also #2423093: Allow multiple target entity types in the 'entity_autocomplete' Form API element
Comment #53
effulgentsia commentedSince this issue is no longer critical, untagging for critical office hours. Don't know if we have or should start a "Major Office Hours" or similar tag. Leaving the "CriticalADay" tag, since maybe that concept still applies to work done while an issue was critical at some point.
Comment #54
xjmSo since this turned out not to be a blocker for the menu link work, I think this is actually a feature request?
Comment #55
jibranI think this is correct let's focus at #2423093: Allow multiple target entity types in the 'entity_autocomplete' Form API element and #2427803: [PP-1] Expose target type, selection handler and selection settings in LinkWidget for now.
I'll keep on improving dynamic entity reference in contrib and I'll make sure we can replace entity reference completely with dynamic entity reference without BC break that's why I moved it to 8.1.x instead of 9.0.x.
Comment #56
jibranComment #57
dpi@larowlan @jibran is the goal still for 8.1?
Comment #59
timmillwoodPatch from #46does not apply any more (which is kinda obvious for a patch that's a year old, but just tagging as needs reroll).
Comment #60
amateescu commented#2423093: Allow multiple target entity types in the 'entity_autocomplete' Form API element would need to happen first.
Comment #64
aaronbaumanParent issue has been resolved, so re-opening this.
Seems like the data type should come before the form widget, no?
ie. #2423093 should be postponed on this issue, and not vice versa.
Comment #68
alienzed commentedbump
this is important guys :P
Comment #69
jonathanshawNo, @amateescu had it right.
#2423093: Allow multiple target entity types in the 'entity_autocomplete' Form API element is about the form element, which is used by the field widget but is more generic.
You could argue that this issue could address the field type only, and then a followup (postponed on both #2423093: Allow multiple target entity types in the 'entity_autocomplete' Form API element and this issue) could address the widget, but as no one is actually working on any of these that's of dubious value.