Drupal views 3 - missing "MULTIPLE FIELD SETTINGS" in entity reference

4.8k views Asked by At

Context: Content type Person has reference (multiple values) to a content type Work, using entity reference.

Need: To display the title of each person node which references a given work, separated by a comma.

Done: A view with a back reference, the right nodes are fetched. (Views 7.x-3.7)

Problem: Cannot display the value separated by a comma. Note: I usually do it with the "Simple separator" display type which is under "Display all values in the same row" in the MULTIPLE FIELD SETTINGS field group. However, this field group is not available in my context.


Solved

I have found the module Views Merge Rows - works very nice. If it does not support Features module for some reason, I can take some of its code code in order to use hook_views_pre_render myself.

4

There are 4 answers

0
Niklaus König On

I had a similar issue, where I was using the Entity Reference relationship of "Referencing Entity" instead of "Referenced Entity". (The reference was on the child and the View started at the parent level).

When you run a Drupal System Message on the row (dsm), it returns all the nid responses appropriately, but as different result rows instead of as a single object; however, since the NID field (like many others) has no option for display multiple results, it would only grab the first result.

I ended up having to do an Entity Query from a Views PHP field with the current row's NID as one of the Field Conditions. That seemed to do the trick, rather than trying to load a View inside of a View with views_field_view.

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', '[your_content_type]')
->propertyCondition('status', 1)
->fieldCondition('[your_field_machine_name]', '[field_column_to_check]', $row->nid)
->addMetaData('account', user_load(1)); // Run the query as user 1.
$result = $query->execute();
0
tanius On

I had a very similar problem: no "Multiple Field Settings" were available in the field configuration of a multi-value entity reference from my content type to User.

Solved it by removing the entity reference and instead using the multi-value "User ID" field of my content type directly. The "Multiple Field Settings" form area was available now and I selected "Display all values in the same row" there as you do normally. Now this would only display numeric user IDs separated by comma (not desired). But in the field configuration there was also a setting "Format:", which I set to "Label". This would display user names instead.

So I guess by creating a custom formatter you would be able to display your associated "Work" entities in a similar way.

0
TheodorosPloumis On

You need a custom views Format here because you are talking about the whole views-row not a multiple results field. You can use the "Unformatted list" and add a comma to be added with CSS or JS.

What kind of Relationship do you use? Can you export your whole views in an external editor and provide a link?

0
Dave Bruns On

I was able to work around this problem by using token_formatters. The basic steps (after token formatters is installed):

  1. No relationship to referenced entity in views (not needed)
  2. Add the entity reference field to the view
  3. Change formatter to "tokenized text"
  4. For 'Text to output' use a token (I'm using [node:field-name])
  5. For 'link destination' use a token ('m using [entity:url:path] for a relative link)
  6. Set multiple field setting as desired