Closed (works as designed)
Project:
Custom Formatters
Version:
7.x-2.2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Feb 2013 at 05:05 UTC
Updated:
17 Feb 2013 at 06:35 UTC
I created a very simple custom formatter to convert an integer to hours minutes seconds using the format_interval() function.
$element = array();
foreach ($variables['#items'] as $delta => $item) {
$element[$delta] = format_interval($item['value']);
}
return $element;I'm not sure if this is the right way to go about it, but it worked, except I would get this notice on the output page. Notice: Array to string conversion in custom_formatters_field_formatter_view() (line 119 of \sites\all\modules\custom_formatters\includes\field.inc).
to get around this, in custom_formatters\includes\field.inc I changed.
$element[$delta]['#cf_options'] = isset($display['#cf_options']) ? $display['#cf_options'] : array();
to
if(is_array($element[$delta])){
$element[$delta]['#cf_options'] = isset($display['#cf_options']) ? $display['#cf_options'] : array();
}
Comments
Comment #1
2phaIt seems like it was problem with how I was returning the data in the formatter.
The formatter code should have been this instead.