Hello, I create a new type of content named "Collection" for create collections of images.

I have created a field of type "Entity Reference" inside my Collection and created a "Entity Reference" inside View : http://i.imgur.com/JjMdWR6.png

After, when I want create a "Collection of image" from node/add, the form don't display me a list of images with checkbox to select, but a search field with server errors.

Error 1 :
Location http://theming.dev/entity_reference/autocomplete/tags/field_kyna_collect...
Referrer http://theming.dev/node/add/kyna_collection_image
Message Notice: Undefined index: unknown in Drupal\entity_reference\Plugin\views\display\EntityReference->query() (line 143 of /var/www/theming/core/modules/entity_reference/src/Plugin/views/display/EntityReference.php).

Error 2 :
Location http://theming.dev/entity_reference/autocomplete/tags/field_kyna_collect...
Referrer http://theming.dev/node/add/kyna_collection_image
Message Drupal\Core\Database\DatabaseExceptionWrapper: Exception in Images[kyna_images]: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE '%i%' ESCAPE '\\') ))AND(( (node.type IN ('kyna_image')) ))) ORDER BY node' at line 2: SELECT node_field_data.created AS node_field_data_created, node.nid AS nid FROM {node} node INNER JOIN {node_field_data} node_field_data ON node.nid = node_field_data.nid WHERE ((( (. LIKE :db_condition_placeholder_0 ESCAPE '\\') ))AND(( (node.type IN (:db_condition_placeholder_1)) ))) ORDER BY node_field_data_created DESC LIMIT 10 OFFSET 0; Array ( [:db_condition_placeholder_0] => %i% [:db_condition_placeholder_1] => kyna_image ) in Drupal\views\Plugin\views\query\Sql->execute() (line 1442 of /var/www/theming/core/modules/views/src/Plugin/views/query/Sql.php).

Comments

Kyna’s picture

Issue summary: View changes
tim.plunkett’s picture

Version: 8.0.0-beta3 » 8.0.x-dev
Component: forms system » entity_reference.module
Priority: Critical » Major
Issue tags: -form, -image, -Entity Reference
holist’s picture

I believe I have the same issue on beta10 (same error messages, mutatis mutandis). I do not refer to images in my entity reference fields, and actually for me it works as expected with checkboxes or select list. With autocomplete fields (either type) the throbber just dies and the errors are logged.

I use a view with taxonomy term relationship to provide the list of referable entities, specifying the tid in field configuration.

In the error message the issue seems to be with the dot in this part: WHERE ((( (. LIKE :db_condition_placeholder_0 ESCAPE '\\'). What causes this, I cannot guess. If there is a way to get trace from AJAX queries and it would help, I will try to get more info. Might even try fixing it myself if I knew where to look, as it is a major issue for my project.

DuaelFr’s picture

Issue tags: +HappyDays1506
Haza’s picture

Title: Use images as Entity Reference don't work » Using a views in entity reference field as the "Reference method" fails

I guess the issue is more global.

What I have tested :
- Set up a content type A that have an entity reference to an entity type B,
- In the options of the entity reference field, set up the "Reference method" to use a view (obviously, create the view),
- Be sure to use the "Autocomplete" in the "Manage form display" for our entity reference field,
- Create a few content of type B, to have some test data.

Now, just create a new content of type A. When using the entity reference, it just dies and the error is logged.

Berdir’s picture

Title: Using a views in entity reference field as the "Reference method" fails » Use images as Entity Reference don't work

That's a completely different issue, which has an issue with patch: #2482625: Views entity reference selection with autocomplete widget broken.

Haza’s picture

So, as I understand the #1, this one should be a duplicate. If you look at the screenshot, he's referencing a content type that contains an image field.

Berdir’s picture

Sorry, you are right, it seems to be the same problem. That means this should probably be closed as a duplicate since the other has a patch. Can you verify that the referenced issue solves this problem and if so, set the status to Closed (duplicate) ?

Haza’s picture

Status: Active » Closed (duplicate)

I can confirm that the linked patch solves the problem.