I noticed today that if you have multiple entityreference_view_widget widgets on the same page, they will interfiere with each other.

1) Changing the page would change the page on both widgets. Fixed it with: http://drupalcode.org/project/entityreference_view_widget.git/commitdiff...
2) Using the "Apply" button to change the exposed filters would kill the selection on the left (with the form state having weird data, from the other widget).
I'm guessing that the problem comes from this code in our exposed form plugin:

// The button basically doesn't work with JS on or off, without this.
$form['submit']['#name'] = 'apply';

Would be great to know why that line is needed, how to make it not needed, or at least make it work. I tried making the #name unique, and that makes
it work, but only for one widget (which ever I choose first works, the second one fails to work).

Comments

bojanz’s picture

Note that Views sets #name to an empty string:

  $form['submit'] = array(
    '#name' => '', // prevent from showing up in $_GET.
    '#type' => 'submit',
    '#value' => t('Apply'),
    '#id' => drupal_html_id('edit-submit-' . $view->name),
  );

I tried just unsetting #name and letting nature (Drupal) do its thing, but it still doesn't work.
When the selection disappears, watchdog tells me that the widget received a partial form state array, containing only the values of the OTHER entityreference widget, which is definitely odd.

damien tournoud’s picture

Status: Active » Needs review
StatusFileSize
new2.08 KB

So the problem is that we cannot rely on the form values because of #limit_validation_error. We need to store the items in the field state.

All this needs a lot of clean-up, but we are moving forward :)

bojanz’s picture

I've committed the patch in #3.
Leaving the issue open so that I can later go through this and confirm that the issue is completely gone.

zambrey’s picture

Hey, seems like last commit broke exposed filters. At least for me :)
After switching to latest dev the exposed filters in reference view doesn't apply. View always shows original results.
Here's the patch that fixed that.

bojanz’s picture

Makes sense, will commit that as soon as I regain git access (weekend probably, I'm onsite with a client currently).

bojanz’s picture

Status: Fixed » Closed (fixed)

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