To replicate:
Create necessary view with Entity Reference and Entity Reference View Widget displays.
Add to content type.
Create content of that type.
Add an item
Select an option, then click "Add Items and Close Window"

Comments

malovanets’s picture

What cardinality do you have in your field settings? You probably had selected more items that is allowed and should have an error message inside your modal. Scroll it up to check. In this case it's natural that the window won't close.

bennos’s picture

same problem.
tried it with unlimited values and only one value.

"Add items and close" maybe does not work because of a JS error.

Uncaught TypeError: Cannot read property 'field-test-views-reference-values' of undefined entityreference_view_widget.js?mzpt6t:47

Browser: Chrome 32
Jquery and UI: 1.10

My install has jquery compatibility installed, so it should work.

Maybe the jquery version is to high. I trie it in a vanilla install.

bennos’s picture

Priority: Normal » Major

hm. Tried it on a vanilla install.
No JS errors.

"Add items and close" also does not work. No errors, no message.
Only one item can be added and only one item is added.

As the widget does not close after adding items, I mark this a major bug.
Think this a thing, that should work.

malovanets’s picture

Would really appreciate if everyone who has this issue will mention their version of jQuery. The mine is 1.4.4 (which comes with Kickstart). I will test it against more recent versions.

malovanets’s picture

It's working up until 1.8.2 for me. Versions 1.9, 1.10 seem to be incompatible with Ctools. In my case I can't even open the overlay. I would recommend to use jQuery Update and set an alternative older version for admin pages now.

asparaguscat’s picture

Where do I find my jQuery version?

malovanets’s picture

asparaguscat, just look at your HTML sourcecode and find a line like this:

<script type="text/javascript" src="http://yoursite.com/misc/jquery.js?v=1.4.4"></script>

or this:

<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>

You may also look at the sourcecode of the jquery library itself. It usually has the version commented in the beginning of the file.

fulminado’s picture

I have the same problem. I think :-)

I have install the module along with entity reference.
-I use a content type with a field collection lets call it A
-I also use a content type with an Entity Reference field, which i ll refer to as B
-I have a View with two displays:
-An Entity Reference where I have as fields (from content type's A field collection):
-The Field collection item ID (which I also use as the Search Field)
- The Field collection item: photo and
- The Entity Reference View Widget Checkbox
-An Entity Reference View Widget where
I select Unformatted list and Show:Rendered entity

Now on Entity Reference Field on content type B, I use
-Widget Type: View
- Entity Selection -> Mode: Views and I select my View

When I create a new content of content type B, (I already have created some content type A nodes), i click Add Item. The modal shows my field collection items, but when i select some of them and click add, the box doesn't close and the page on the back shows as filed's content the localhost.

Thanks for any help and sorry for the long post.

Have a nice day and keep up the great work!!!

nhck’s picture

Vanilla Drupal 7 (jquery 1.4.4) here.
The problem is related to this part in the entityreference_view_widget.js which causes the script to fail and stop.

              if (!el.find('.tabledrag-handle').length) {
                Drupal.tableDrag[widget_settings.table_id].makeDraggable(el.get(0));
                el.find('td:last').addClass('tabledrag-hide');
                if ($.cookie('Drupal.tableDrag.showWeight') == 1) {
                  el.find('.tabledrag-handle').hide();
                }
                else {
                  el.find('td:last').hide();
                }
              }

More specifically:

  • Chrome reports: Uncaught TypeError: Cannot call method 'makeDraggable' of undefined
  • Firefox: TypeError: Drupal.tableDrag[widget_settings.table_id] is undefined entityreference_view_widget.js:47

The cause of this is that if you allow only a single value - the table isn't made Draggable. Maybe adapt line 46 to check whether the cardinality is greater 1?

if (!el.find('.tabledrag-handle').length && widget_settings.cardinality > 1) {

instead of if (!el.find('.tabledrag-handle').length) {

I am not familiar enough with the code to understand the underling consequences. Thanks

barboite’s picture

same as fulminado !

When I add items, the form just shows WAMP localhost page. Also the page style breaks when the pop up appears (everything gets smaller). I'll try to fix this but any help is welcome, I can't just get previous Jquery versions because other modules depends of it. thx

castfaraway’s picture

I had the same issue.

What i found is, if i set Number of Values = Unlimited under the field settings, the window closes.

Looks like when you set number of values =1 and then hit the button "select items and close" it cannot handle it and does not work.

malovanets’s picture

That's right. The bug appears only if the cardinality is 1. Fixed it in the dev release.

malovanets’s picture

Status: Active » Fixed
bennos’s picture

confirming
works now.

fulminado’s picture

Changed version to alpha2 and the number of values to unlimited and works great :-)
Thank you :-)

Status: Fixed » Closed (fixed)

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

thelocaltourist’s picture

This is still not working when the cardinality is 1. The selected item is added to the field but the modal window doesn't close upon clicking Submit. Works fine with cardinality is unlimited.

thelocaltourist’s picture

Status: Closed (fixed) » Active

Reopening

jsacksick’s picture

If you check the option "Close modal window after submitting the items" on the field widget settings form, it will be closed automatically, are you suggesting to close it when you actually reached the number of allowed values?

jrochate’s picture

I can confirm that is still no closing automatically when ONE value is allowed.

Configure field settings for more that ONE value, and the modal closes as configured.

Already tried dev version, and same behavior.

Thx

Adrian Richardson’s picture

Version: 7.x-2.0-alpha1 » 7.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new1.31 KB

Yep, I can confirm this happens for me too when cardinality=1

In theme_entityreference_view_widget_widget() draggable classes are only added if $settings['field']['cardinality'] !== '1'

Patch attached to check there are drag handles available before trying to work with them in the JS.

jsacksick’s picture

Status: Needs review » Fixed

A different fix has been committed (We just don't call anymore entityreference_view_widget_command_draggable()) when the cardinality is 1. See 515d6b1

  • Commit 515d6b1 on 7.x-2.x by jsacksick:
    Issue #2177207: Call entityreference_view_widget_command_draggable()...

Status: Fixed » Closed (fixed)

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