Hello,

I'm getting this error when loading the edit form of a node with a Relation Select field:

relationSelectItems[id] is undefined
http://***/sites/all/modules/relation_select/js/relation-select.js
Line 187

I just fixed it with this patch:

--- relation_select/js/relation-select.js.orig	2011-10-23 16:06:00.000000000 +0200
+++ relation_select/js/relation-select.js	2011-10-23 16:09:41.000000000 +0200
@@ -183,8 +183,8 @@
        * Get input
        */
       function getInput(id, entitydata){
-        return $('input[value="' + entitydata + '"]',
-            relationSelectItems[id]['element']);
+        return (relationSelectItems[id]) ? $('input[value="' + entitydata + '"]',
+            relationSelectItems[id]['element']) : [];
       }
 
       function countArity(id){

Regards,
Maurizio

Comments

Yuri’s picture

I conform that this solved an issue for the latest dev version, in which (re)selecting a bundle and adding the relation was not possible.

Anonymous’s picture

Have the same same problem, its something with wysiwyg that makes this error.
relationSelectItems[id] is undefined
[Break On This Error] relationSelectItems[id]['element']);

bwoods’s picture

The patch seems to work but doesn't completely allow me to do what I need in my case. I'm using this module plus the Wysiwyg module. The issue is that the text area that allows HTML is being counted by the Relation Select module when allowing values to be selected. Instead of using the patch listed above, I made these modifications:

Starting at line 64

      function addRowEventHandlers(context){
 +       // Check selected & add event handler: row clicked
 +     	if (context == '[object HTMLDocument]') {
 +     		return;
 +     	}

        $('tr:not(.processed)', context).each(

This automatically removes the initial text area field on edit page load.

Starting at (updated) line 144

      function handleRowClick(id, $row){
+      	id = "edit-field-related-topics-und-0-endpoints";
        var entitydata = $row.attr('data-entity');

I'm setting the ID variable to the name of my field. THIS IS NOT THE PROPER WAY TO DO THIS. But for now, this works for me.

imiksu’s picture

StatusFileSize
new504 bytes
new524 bytes

Here are some patch files. A version is solution in description and B version is @bwoods without second edit (since it's not proper way as he said, and i agreed).

ensignavenger’s picture

I'm not sure if the two issues are the related, but I am having the same problem in two different places. Patch A resolves the error on line 187. However, I am getting the same error on line 193 (The countArity function).

I don't know enough JS to figure out how to fix it.

Also, patch B did not work for me, perhaps because it does not have the second edit or because I am not using WYSIWIG.

I opened another issue at http://drupal.org/node/1435980 which might be considered a duplicate of this one, if it is determined that the two are related.

Gray Fox’s picture

StatusFileSize
new2.01 KB

Review needed on this patch.

Gray Fox’s picture

StatusFileSize
new1.41 KB

Resubmitted patch from #6, cygwin behaves strange with Windows paths.

chromix’s picture

Patch works for me. Thanks guys!

cbergmann’s picture

hi,

I also have this problem. applying the patch A from #4 solved the problem in line 187 but that leaves me with the line 193 problem. I am using wysiwyg with fckedit.

cbergmann’s picture

I also note that the problem occurs only while clicking on the first search results. When you hit the "Search" button once more you can select an entry and it will be added fine.

cbergmann’s picture

a workaround for this problem is using fckedit which is, according to first test, not conflicting with relation_select.

ben_scott’s picture

Status: Needs review » Fixed

Hi -

Thanks very much for the patches - I've applied the patch from #7 which seems to fix the issue.

Cheers,

Ben

Status: Fixed » Closed (fixed)

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