While I am aware that the 'title_linked' formatter was probably never meant to be used on anything besides the actual title field, I have found it quite useful for some other fields. And this is where I ran into the problem that the field formatter simply always takes the first value of a field and nothing more. See the title_field_formatter_view function

function title_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
   $settings = $display['settings'];
   $output = isset($items[0]) ? $items[0]['safe_value'] : '';
   $element = array();
   ...

This seems quite pointless since the assumption behind this is simply not necessary. I propose the attached fix to allow the formatter to handle multiple deltas. The change is perfectly backwards compatible unless somebody using this is actually relying on the fact that the formatter ignores deltas.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Pol’s picture

Hi,

The patch is valid but I don't think it will be committed.
The Title module sync it's value with the title property of the entity it's hooked to.

If we enable multiple field values, how are we going to deal with that ?

getu-lar’s picture

Hi Pol

I think you're missing my point. The formatter applies to any text field, not just the title field and is quite useful for exactly that purpose. There is no reason to limit its functionality to what the title field can support. I'm not suggesting to allow multiple values on the title field (I'm not that crazy), I'm using it on quite a lot of other fields.

Admittedly, after two and a half years I'm not holding my breath on whether or not this will be committed, but it's nice that at least somebody responded.