Hi at all,

although I gave multiple values in reference fields, what you can see with the devel module:
devel

it shows only the first field.

Content

What can I do against this phenomenon???

Thx in advance,

maen

CommentFileSizeAuthor
Hallo_devel.png65.61 KBmaen
Hallo_content.png9.45 KBmaen

Comments

maen’s picture

OK, found the problem.

Line 340:

$field_items = field_get_items($field_entity_type, $field_entity, $item['field_key'], $field_language);
      if ($field_items) {
        foreach ($field_items as $delta => $field_item) {
          $result[$delta][] = field_view_value($field_entity_type, $field_entity, $item['field_key'], $field_item, $field_display, $field_language);
        }
      }

The brackets after $result[$delta] were missing.

dmoonman’s picture

This is a good find. However, what would need to be done to wrap each of the results produced here with a specific type of HTML tag?

This fix produces SPAN wrappers, but what if we wanted to wrap each result as with an LI tag.

I tried the following but this returns nothing;

<?php
$field_items = field_get_items($field_entity_type, $field_entity, $item['field_key'], $field_language);
      if ($field_items) {
        foreach ($field_items as $delta => $field_item) {
          $result[$delta][] .= '<li>';
          $result[$delta][] .= field_view_value($field_entity_type, $field_entity, $item['field_key'], $field_item, $field_display, $field_language);
          $result[$delta][] .= '</li>';
        }
      }
?>

maen’s picture

If you return result[$delta] instead result, you'll get the rendered output by drupal. So there are the usual li items.

  • danielb committed 1437173 on 7.x-1.x
    Issue #2139869: Shows only 1 value in multi value reference field
    
danielb’s picture

Status: Active » Fixed

Fixed with spans. Hook into the render array if you want to change it from spans to something else.

Status: Fixed » Closed (fixed)

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