Problem/Motivation
On the field settings, when we select "Search Dialog" and we use "Views" instead of "Simple" (see screenshot) for the entity selection, the following warning/notice is shown:
Notice: Undefined index: type in references_dialog_entityreference_add_link() (Zeile 247 von /var/www/sites/all/modules/contrib/references_dialog/references_dialog.dialog_widgets.inc).
Warning: array_keys() expects parameter 1 to be array, null given in references_dialog_entityreference_add_link() (Zeile 250 von /var/www/sites/all/modules/contrib/references_dialog/references_dialog.dialog_widgets.inc).
Proposed resolution
The filter option has to be checked.
I will provide a patch for that.
Comments
Comment #1
weri commentedComment #2
sgdev commentedThank you for the patch... I can confirm this fixes the issue.
Comment #3
recrit commented#1 patch fixes the notices, however, an field configured to use an un-filtered user view still does not get an add link.
The attach patch checks if any bundles were found after all the possible bundle determination logic.
Comment #4
marcopbazz commentedI try patch #3 with an entityreference field with bundle filtered by views. In my case I need to reference a taxonomy term for a specific vocabulary.
The add link appear for each vocabulary instead....
Comment #5
nishruu commentedI have the same problem as @MarcoPBazz. I think it's odd that we always check for the "type" bundle key, only because we are using the "view" mode. For example, taxonomy terms use "machine_name" instead of "type".
As we cannot be sure of the bundle key, we should look for the right one instead of retrieving all the bundles as the previous patch does.
Maybe I'm missing something because it's possible the code in "references_dialog_entityreference_views_query" is made for this ? If not, here is my patch.
Comment #7
marcopbazz commented@Nishruu I try your patch but it didn't work....Maybe i'm missing something with the view? i'ts a simple view filtered by vocabulary (i'm using latest dev version of this module and the latest stable release of entity reference).
Comment #8
nishruu commentedYou should use a filter on "vocabulary : machine name".
nb : the patch failed testing probably because i'm on dev. I'll submit it for the stable later.
Comment #9
marcopbazz commentedGot it, i was filtering by taxonomy term vocabulary. Changing to vocabulary : machine name solved the problem, and now it works!
thank you so much
Comment #10
weri commented@Nishruu: You have to cleanup your patch. The patch uses the full path of your local environment. Change all paths like the following:
a/core/sites/all/modules/contrib/references_dialog/references_dialog.dialog_widgets.inc
to
a/references_dialog.dialog_widgets.inc
Comment #11
nishruu commentedThanks for the tip.
Comment #12
nishruu commentedComment #14
nishruu commentedWrong patch again, sorry. I hope this time it's ok.
Comment #15
nishruu commentedComment #17
WorldFallz commentedalso resolved #2398545: Notice: Undefined index: type in references_dialog_entityreference_add_link()(line 247 of .../references_dialog.dialog_widgets.inc).
Thanks everyone!
Comment #19
donquixote commentedThis introduced a bug.
"Notice: Undefined variable: views_filters in references_dialog_entityreference_add_link()"
There is no final
else {case.So it is no longer guaranteed that
$views_filtersis defined.Comment #20
iamweird commentedIt seems I've got #19 fixed by propagating to using all bundles if there are no bundle keys (e.g.
userentity doesn't have any) and also using all bundles if there's no filter set by bundle key in the view so$views_filtersis left undefined.Comment #21
WorldFallz commentedLooks good to me-- thanks for the patch. Can we get 1 more person to apply the patch and test?
Comment #22
sgdev commentedHave tested out the addition and seems to work as I would expect. Thanks.
Comment #23
marksmith commentedPatch #20 works for me too. Thank you!