Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
yched CreditAttribution: yched commentedTrue, 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.
Comment #2
yched CreditAttribution: yched commentedShould be fixed now in latest -dev (you'll need to wait a few hours for the tarball to be generated)
Comment #3
gddgot it out of cvs and it works great. thanks!
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.