I think it would be amazing if we could use the field style for this widget, so we have a little more control of what it displays.

Thanks this is awesome!

Comments

sreese’s picture

Seconded. It would be wonderful if we could customize the fields that are displayed by this widget in the view display.

bojanz’s picture

This is not something I have time for right now.
If someone else wants to give it a shot, patches are welcome.
The main problem is that the left column has entities rendered using entity_view(), while the right column has entities from a View. So the new approach would need to have an embed view in the left sidebar.

That said, you can already control which fields get displayed through the "Manage Display" tab of the Field API for the entity type you're displaying (if it's nodes, then it's in Admin -> Structure -> Content Types, etc)

7wonders’s picture

And if you want to slim it down to the bare minimum you can create your own .tpl for entityreference_view_widget. Add to your template.php in your theme:

/**
* Implements hook_preprocess_node().
*/
function THEMENAME_preprocess_node(&$vars) {
  if($vars['view_mode'] == 'entityreference_view_widget') {
    $vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__evw';
  }
}

Now you can create node--YOURCONTENTTYPE--evw.tpl.php. In mine I have placed:

      <header>
        <?php if ($title): ?>
          <label>
              <?php print $title; ?>
          </label>
        <?php endif; ?>
      </header>
    <?php print render($title_suffix); ?>

    <div<?php print $content_attributes; ?>>
    <?php
      hide($content['comments']);
      hide($content['links']);
      print render($content);
    ?>
    </div>

Which prints only the node title and the checkbox (as I disabled all other fields on the Manage Display settings).

mrpauldriver’s picture

A table view with a select box would be most useful for the right column, I'm not too bothered what the left column does.

davidseth’s picture

I have created a new module that allows for much more flexibility in creating the view. You can use the table view layout and add any addition fields you want. It also is much more light-weight in its implementation with less ajax calls back to Drupal.

I made my module due to a large Drupal site I was working on, the Entity Reference View Widget just wasn't scaling due to all the form processing it was doing along with every click being a big ajax call. I did base parts of my module on Entity Reference View Widget and it would be interesting to see if some of these things could be merged back into this project.

It is currently in a sandbox: http://drupal.org/sandbox/davidseth/1489176. You will have to check out the 7.x-1.x branch.

bojanz’s picture

I'll take a look as soon as possible.
Entity Reference View Widget is far from ideal (it is a giant hack basically), and I'm very interested in exploring alternatives.

bojanz’s picture

Status: Active » Closed (duplicate)