I'm creating a view that lists Users with an Entity Reference display, so I can add it to a field. When I add the display to the view I get the message 'Display "Entity Reference" needs a selected search fields to work properly. See the settings for the Entity Reference list format.'

When I go to the list format, there are not Search Fields listed. How do I add them? What am I missing? Or is this a bug?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Nimajn’s picture

I have the same problem.

Matt B’s picture

Category: support » bug
drasgardian’s picture

Version: 7.x-1.0-rc5 » 7.x-1.x-dev

remains an issue in the latest dev

JvE’s picture

The module sets the #default_value of a checkboxes element to $this->options['search_fields']
this can be NULL, while the only allowed value is an array.

A patch to change
'#default_value' => $this->options['search_fields'],
to
'#default_value' => isset($this->options['search_fields']) ? $this->options['search_fields'] : array(),
is attached.

JvE’s picture

Status: Active » Needs review
rwilson0429’s picture

I was able to set an Entity Reference search field without the use of the patch.

You can select your entity reference search field by doing the following:

  • Go to your Entity Reference display in your View
  • Set your display format to Entity Reference list (this should already be the case since you created an Entity Reference Display)
  • Under the Format Section, click the 'Settings' link
  • Select your Entity Referenc Search Field

entityreference display search

If this doesn't work, apply the patch in #4, flush caches, then follow the steps above.

cinnamon’s picture

For me the solution was to update views and ctools. This patch did nothing

seafront’s picture

I found checking the search fields box in the entity ref list settings as rwilson0429 suggested worked - but the error message remained until I'd saved the view. At which point it vanished.

Usability for this ought to be addressed.

JvE’s picture

The patch addresses a code bug where a variable that can be NULL is used in a place where only an array is allowed.

If you have error reporting on (recommended during development) you will get a "Warning: Invalid argument supplied for foreach() in form_type_checkboxes_value()" when you click on Settings in the Format section.
This will prevent you from reaching the screen rwilson0429 shows and creating the display.

Yaron Tal’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #4 works for me.
Without the patch I get

Warning: Invalid argument supplied for foreach() in form_type_checkboxes_value()

To reproduce:
1. Create a new view with no page or block.
2. Add an Entityreference display.
3. Click on "Settings" for the format.

Step 3 gives me an error. The patch fixes this.

intrafusion’s picture

I can also confirm that the patch in #4 works for me and the steps to reproduce in #10 are correct.

Please can we get this applied to the module and new release created? #2050653: Roll a 1.1 release?

ctapial’s picture

I confirm that #6 did the trick for me. So simple...

rwohleb’s picture

Issue summary: View changes

Yep, patch from #4 worked for me. Since this has been reviewed/tested, let's get this committed :)

morsok’s picture

Patch 4# worked for me too. Thx !

nmancini’s picture

Patch worked for me - thanks much!

sonicthoughts’s picture

#10 worked for me. drush cc, change settings. Not at all intuitive thought.

electrocret’s picture

#4 worked for me. Thanks!

shailu29’s picture

#10 worked for me

eawheeler’s picture

Applying the patch in post # 4 to 7.x-1.1 resolved this for me.

sonicthoughts’s picture

Please commit.

jami’s picture

Patch 4 fixed this for me as well. Thank you!

gparsloe’s picture

#6 just worked for me.

prsnjtbarman’s picture

#6 solves the problem

bmateus’s picture

Had this problem again... Patch #4 solves it, could not access the instructions in #6 as it breaks with an AJAX error.

thmohd’s picture

Patch 4 is for dev. do you guys have patch for the released version.

andrbmgi’s picture

#4 worked for me in 7.x-1.1 (not dev) had AJAX error before.

bohemier’s picture

Just had this problem too. Using a drupal 7.42 with views 7.x-3.13 & entityreference 7.x-1.1. Patch in #4 resolved the issue.

owntheweb’s picture

I just had this issue with Drupal 8.1.1. To reproduce:

  1. Create a page view.
  2. Set the format to Table.
  3. Add an Entity Reference display. The error occurs. Choosing any of the format options results in the same error.

Workaround:
After seeing the error, in a new tab, clear the cache at Configuration -> Performance. Refresh the views tab and choose Settings next to Format: Entity Reference list.

UPDATE:
I posted this under the wrong issue (wrong version of Drupal). Apologies, coffee still soaking in...

calefilm’s picture

Confirm #6. Thank you.

arunkumark’s picture

Patch #4 Working Fine.

  • spotzero committed 599b075 on 7.x-1.x authored by JvE
    Issue #1810434 by JvE, Matt B, rwilson0429: No search fields to select...
spotzero’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.