When using the autocomplete widget and I search for "Document Title" I see all entities matching "Document title", however I only see 10 at a time. In my use case I am connecting multiple documents to an event content type. Could we list more than 10 items at a time? At first glance it seemed as though the field could not find the nodes, some people will be confused.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jygastaud’s picture

Project: Entity connect » Entity reference
Component: Feature Request » Code

@thoughmas,

I'm moving that issue to Entity Reference too as it's not concern directly Entity connect.

aniebel’s picture

I would consider this a fairly important request since it appears that there are 10 or fewer results while in reality, it could be a lot more.

fbrooks’s picture

I am providing a patch for consideration that contains this functionality.

Thanks

nategasser’s picture

Patch in #3 worked great, thanks.

gazzur’s picture

Patch #3 works fine for me.

saniyat’s picture

Status: Active » Reviewed & tested by the community

Patch #3 works perfectly.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 3: entityreference-autocomplete_max_results-2185019-3.patch, failed testing.

Kris77’s picture

Patch #3 works fine for me too.
I use EntityReference 7.x-1.1 and Drupal 7.50

MustangGB’s picture

Version: 7.x-1.0-rc1 » 7.x-1.x-dev
Status: Needs work » Reviewed & tested by the community

Nice idea, test failure was unrelated to the patch and a re-run now passes fine, so marking RTBC as per #6.

spotzero’s picture

Status: Reviewed & tested by the community » Needs work

This throws a warning unless you re-save everything.

Notice: Undefined index: max_results in entityreference_autocomplete_callback_get_matches() (line 1063 of /var/www/html/drupal/sites/all/modules/entityreference/entityreference.module).

NWOM’s picture

#3 worked perfectly. Thank you!

dani3lr0se’s picture

Status: Needs work » Reviewed & tested by the community

#3 worked well for me as well. Thanks! I'm going to change this back to reviewed and tested by the community since it worked without any issues.

minorOffense’s picture

Status: Reviewed & tested by the community » Needs work

I haven't seen anyone address @spotzero's warnings. Putting back to needs work.

fbrooks’s picture

@spotzero can you provide the steps for recreating the warning?

Thanks

spotzero’s picture

  1. Install site with a release of entity reference
  2. Setup any entity reference field, it doesn't mater
  3. Apply the patch
  4. Go to the field settings form for your entity reference field

Just make sure that "$settings['max_results']" exists before using it, because it doesn't exist until the setting form is re-saved.

fbrooks’s picture

I am unable to reproduce the warning on 7.54 with the latest 7.x-1.x-dev of entityreference. I created a content type, added an entityreference field, applied the patch, and then edited the entityreference field's settings. I am seeing no warnings.

@spotzero, could you retry with the HEAD of 7.x-1.x?

Thanks

FrancescoQ’s picture

Status: Needs work » Reviewed & tested by the community

I applied #3 and i had the warnings, but everything went fine after flushing all cache.
I think the issue simple was that without flishing the caches the field doesn't read the default of 10 elements to show (the field was empty until the flush, but showed '10' after the flush)
I think this is RTBC
Thanks!

@spotzero if you download entityreference, apply patch, then create fields everything goes right first try, i think the issue exists only for already existing fields.

Alex72RM’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

Hope to have the patch applied to -dev ;)

MustangGB’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

Patch does apply against dev, and that's not what the "Patch (to be ported)" status is for either, so restoring status.

joep.hendrix’s picture

Patch #works fine, please commit

minorOffense’s picture

Status: Reviewed & tested by the community » Needs work

To avoid warnings after applying the patch, if all that's required is a cache clear, we'll need an update hook to trigger a cache clear (technically speaking update.php should clear the cache anyways so we could get away with an "empty" update hook but I'd prefer an explicity cache clear call).

Moving to "needs work" so we can add the update hook.

bramvandenbulcke’s picture

I wanted to change the autocomplete output to 50 on a website with different related content fields. I only needed to change the value under 'Get an array of matching entities' from 10 to 50:

// Get an array of matching entities.
$entity_labels = $handler->getReferencableEntities($tag_last, $instance['widget']['settings']['match_operator'], 50);
vinmassaro’s picture

Status: Needs work » Needs review
FileSize
2.55 KB

@minorOffense: here is an updated patch that flushes caches in an update hook. Thanks!

squarecandy’s picture

#23 works great. Thank you.

estebanvalerio.h’s picture

Since DEV version was updated today, patch #3 was giving errors due to lines mismatch, here's an update for patch #3.

joelpittet’s picture

@estebanvalerio.h not sure if you meant to remove the cache clear form #23, but here's a patch that is a bit more specific and less drastic of a clear.

field_info_cache_clear(); instead of drupal_flush_all_caches();

LMK if it needs more clearing.

ultrabob’s picture

Status: Needs review » Reviewed & tested by the community

I tested #26 in desktop browsers and smartphone. Because I applied a patch I still had to clear cache to avoid errors showing up, but once I cleared cache it worked like a charm everywhere I tested it.

scotwith1t’s picture

+1 for this one! Let's get it in and 1.6 release out! :)

minorOffense’s picture

We still need a test to validate the functionality. If anyone is feeling keen enough to add the test.

welly’s picture

Status: Reviewed & tested by the community » Needs work

Ignore me, it's fine.

welly’s picture

Status: Needs work » Reviewed & tested by the community
darkodev’s picture

Isn't this already addressed here? https://www.drupal.org/project/entityreference/issues/1700112

We've been using that patch for a while and it works great.

joelpittet’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

Thanks for pointing that out, the other one is better but missing entityreference_field_widget_info changes that this one is, and the cache clear.

Closing as a duplicate of #1700112: Entity reference list View Pager: Items to display is broken