This could potentially be a Views bug, but I'll start here.

CCK 6.x RC 10
PHP 5.2.6

I have a multiple-instanced text field using a custom text field formatter the turns the multiple instances into a comma-delimited list. In the node page this works great. However in Views, this field displays very weird results such as

l, 1, R
l, 1, R
l, 1, A

I have pasted the code for the formatter below. To reproduce just create a content type with a multiple-instance text field, create a view which displays the field, and set the view to use the formatter below. Let me know if I can provide more details.

function textcommaformatter_field_formatter_info() {
  return array(
    'text_comma' => array(
      'label' => t('Comma-separated'),
      'field types' => array('text'),
      'multiple values' => CONTENT_HANDLE_MODULE,
    ),
  );
}

function textcommaformatter_theme() {
  return array(
    'textcommaformatter_formatter_text_comma' => array(
      'arguments' => array('element' => NULL),
    ),
  );
}

function theme_textcommaformatter_formatter_text_comma($element) {
  $values = array();
  
  $item = $element;
  foreach (element_children($element) as $key) {
    unset($item[$key]);
  }
  
  foreach (element_children($element) as $key) {
    $item['#item'] = $element[$key]['#item'];
    $values[] = ($allowed =_text_allowed_values($item)) ? $allowed : $item['#item']['safe'];
  }
  
  return implode(', ', $values);
}

Comments

yched’s picture

True, there's currently nothing in the code of content_handler_field_multiple::render() to handle the case of formatters that take care of multiple values.

BTW, using a 'multiple value' formatters to have comma delimited output is a sad workaround - but a valid one unfortunately.
We really miss some notion of 'multiple value display' plugins : divs, spans, custom char separated... Sigh... Well, that's another issue.

yched’s picture

Status: Active » Fixed

Should be fixed now in latest -dev (you'll need to wait a few hours for the tarball to be generated)

gdd’s picture

got it out of cvs and it works great. thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

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