I create a new content type with a Node Reference field. Not select any node bundle for limit reference node type.
I use the Inline Entity Form to add existing node. The auto-complete only appear something like Array (article).
After read through the code and compare with Entityreference module, I see the bug:
-- Around the line #1045:
foreach ($entity_labels as $entity_id => $label) {
$key = "$label ($entity_id)";
// Strip things like starting/trailing white spaces, line breaks and tags.
$key = preg_replace('/\s\s+/', ' ', str_replace("\n", '', trim(decode_entities(strip_tags($key)))));
// Names containing commas or quotes must be wrapped in quotes.
if (strpos($key, ',') !== FALSE || strpos($key, '"') !== FALSE) {
$key = '"' . str_replace('"', '""', $key) . '"';
}
$matches[$prefix . $key] = '
';
}
This should be change to
-----
foreach ($entity_labels as $value){
foreach ($value as $entity_id => $label) {
// entityreference has already check_plain-ed the title.
$results[] = t('!label (!entity_id)', array('!label' => $label, '!entity_id' => $entity_id));
}
}
---
Sorry, I cannot create a diff for this. But after change this, the plugin works normal.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | inline_entity_form-autocomplete-callback-fix-1843316-6.patch | 1.03 KB | jpstrikesback |
| #2 | inline_entity_form-autocomplete-callback-fix-1843316-2.patch | 1.37 KB | eiriksm |
Comments
Comment #1
tky commentedI have the same issue here.
I used 7.x-1.0-rc1 initially, but the autocomplete field for adding existing node gave me somehting like "array(content type)". I have updated this module to 7.x-1.x-dev, still got this error as well.
Hope this can be fixed soon.
Comment #2
eiriksmAttached patch fixes the issue for me. Please review and consider commiting.
Comment #3
darkodev commentedThanks very much. Patch works for us.
Comment #4
malberts commented#2 Works for me. I tested it with Entity Reference fields (Node) that allow only 1 bundle type and another that allows multiple bundle types.
I don't think I'm allowed to mark this RTBC (just 2 reviews), but this is quite a big fail when using IEF.
Comment #5
rob c commented#2 seems to work ok and really opens up this module to huge number of cases, including simplenews content selection. See How to create a newsletter containing existing content, using entity reference, rules and VBO for an example of this.
Comment #6
jpstrikesback commentedThanks eiriksm! This works, I would RTBC it but it needs to pass tests first, so here it is as a git compatible patch.
Comment #7
jpstrikesback commentedOh well, looks like tests aren't running for IEF...if someone can confirm the patch applies we can RTBC this.
Comment #8
eiriksmThanks for testing.
My patch is very much git compatible (did you not test it?). It is only different from yours in the way that i have used
git format-patchto make it. That way the maintainer can usegit amto apply the patch, to save himself 33 seconds of writing the commit message and stuff like that. :)Since you basically have an identical patch (except the header) i would say you can feel free to mark as RTBC if it works for you.
Comment #9
jpstrikesback commentedThanks for the clarification! RTBC, patch in #2 works perfectly!
Comment #10
bojanz commentedTweaked the variable names and committed:
http://drupalcode.org/project/inline_entity_form.git/commitdiff/4b84a37?...
Comment #12
dwalker51 commentedPatch in #2 worked great. Thanks!
Comment #13
ser_house commentedAfter #10 I have warning: "Warning: Invalid argument supplied for foreach() in inline_entity_form_autocomplete() (line 67"
Field options:
"Allow users to add existing nodes.": TRUE
"Target type": node
"Target bundles": my_type (one)
$entity_labels looks like:
Comment #14
vasikei can't reproduce #13 : i get no warning message.
so i think this is closed (fixed).
@ser_house : please try the latest version of the module.
Comment #15
rolfmeijer commentedI still have this issue, both in 7x-1.5 and the dev release of 2015-Feb-26. The error I get is this:
Warning: Invalid argument supplied for foreach() in inline_entity_form_autocomplete() (line 68 of …/sites/all/modules/contrib/inline_entity_form/inline_entity_form.module). Backtrace:
inline_entity_form_autocomplete('node', 'field_questions', 'survey', 'beva')
call_user_func_array('inline_entity_form_autocomplete', Array) menu.inc:517
menu_execute_active_handler() index.php:21
I hope I can find some time this or next week to dive into this (because I really like this module).
Comment #17
bluegeek9 commentedWe appreciate your contributions to Inline Entity Form. Drupal 7 in End-of-Life. We encourage you to upgrade to a supported version of Drupal.