- π¬π§United Kingdom welly
My concern with "works as designed" is using different field widgets exhibits different behaviour.
For example, if you create the entity reference view display, add a contextual filter (Content from URL) and attach it to a field and set the field widget to select or checkboxes or similar then this works as expected - the contextual filter behaves exactly as you'd expect and excludes the current node from the field widget.
However, if you then change this to Autocomplete the behaviour changes - no nodes are returned. I think this needs some consideration as to whether this is broken - to me it is.
While the patch/sandbox module does provide a fix for this, I think this should be the responsibility of core for the behaviour to be consistent across different field widgets.
- π¬π§United Kingdom welly
I've created an example of this behaviour here:
https://master-763xidikw6xdqu8pd9mzr8fbjg3acetr.tugboatqa.com/
You should be able to login with the usual simplytest.me credentials (admin/admin) and if you edit a page:
https://master-763xidikw6xdqu8pd9mzr8fbjg3acetr.tugboatqa.com/node/1/edit
you will see one field with a select widget excludes the current node, the second field using autocomplete does not return any nodes.
This shows broken behaviour to me.
- π¬π§United Kingdom welly
I've attached a config export from the above simplytest.me environment so we can re-build the demo site if needs be.
- πΊπΈUnited States devkinetic
This looks a lot like a duplicate of the following issues:
- π Add Views EntityReference filter to be available for all entity reference fields Closed: duplicate
- β¨ Continuation Add Views EntityReference filter to be available for all entity reference fields Needs work
- β¨ Add Views EntityReference filter to be available for all entity reference base fields Active
- π¬π§United Kingdom AaronMcHale Edinburgh, Scotland
@devkinetic not a duplicate of those issue. Those issues are about making the taxonomy style exposed filter available for all entity types, whereas this issue is specifically about when using an Ajax-based field widget for an entity reference field, it not being possible to exclude the current entity.
On one hand you could argue that this works as designed, because strictly speaking when using an Ajax field widget the current URL is the Ajax request URL, rather than the URL of the page the user is on. However, I don't think that's a helpful way of looking at it, because the result is that the entity reference view behaves differently depending on the field widget that is being used.
Let's take the example of a contrib module that provides an entity reference view, the View has no knowledge of where its going to be used, the users of this module should be able to use the entity reference View and field with any of our Core supported widget and expect consistent behavior.
Therefor, I would argue that this is a problem that Core needs to address because the result is inconsistent behavior with a supported Core feature. I don't think the answer to that should be to say this is a problem to solve in contrib.
Thanks,
-Aaron - π³πΏNew Zealand quietone New Zealand
Drupal 8 is no longer supported. Moving to the main development branch, which is 11.x.