Entity Reference is great. Thanks for this module.

I'm trying to filter the values available in an Entity References "Entity Selection" list on a node edit form to only show nodes relevant to the current node being edited.

I am using views and have selected the "Views: Filter by an entity reference view" for the Entity Selection Mode.

In my view I have created an Entity Reference Display with a contextual filter. I have tested that the contextual filter works the way I want it to by using "Preview with contextual filters" and entering a sample ID to filter on (1200). It filters just fine.

When I use "Display all results for the specified field when the filter value is not available" all the results display on the node edit form. But as soon as I choose "Provide a default value" -> "Raw Value from URL" then nothing is displayed on the node edit form.

I have checked that the raw value is in the URL: content/assembly/1200 (1200 being the value that works in the "Preview with contextual filters") and am using the right path component to reference it and ticking or unticking "use path alias" makes no difference.

Does anyone know why this would not be working?

Thanks very much.


kingswoodute’s picture

Update, If I use Nid I can get the filter to display one value but it should be displaying four values.

It displays four values in the view when I "Preview with contextual filters" but on the actual node itself it only displays the last one that displays on the preview.

finalred’s picture


liquidcms’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Component: Miscellaneous » Code
Category: Support request » Bug report
Issue summary: View changes

i am reasonably sure this used to work at some point.. been busted for a while i think. i have tried numerous different ways of setting up contextual filter and nothing works.. changing this to a bug.

Chris Burge’s picture

I'm having the same issue as @kingswoodute.


I have a entity reference field on a node. It's entity selection mode is 'Views: Filter by an entity reference view'. In the view, I'm using a contextual filter to grab the nid.


The contextual filter works fine when previewing the view but not when editing a node where the field is actually rendered.

This behavior is dependent upon the field's widget type, however. The behavior I describe here only happens when the widget type is either 'Autocomplete' or 'Autocomplete (Tag Style)'. The view correctly processes the nid argument when using other widget types, such as 'Select List' or 'Check boxes/radio buttons'.

3magnus’s picture

I've got to the same point so I tried to emulate the same result using a PHP snipet:
Provide default value -> PHP Code

I tried a looot of snipets and there was no way for Entity Reference to work with uri arguments.

my-family’s picture

I have exactly the same problem. Is there any way to work with dynamic URLs and contextual filters with entity reference?

molnitza’s picture

Is there a work around?

digitgopher’s picture

Status: Active » Closed (duplicate)

Original reported issue resolved in #1, with a bug that is being tracked over in #1688332: Entity Reference view to populate select list for reference field => only one result when using a contextual filter, so marking this as duplicate.

Re #6, maybe try #2010898: Use tokens for entity selection view arguments?