Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
field system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
12 Dec 2009 at 03:00 UTC
Updated:
3 Jan 2014 at 01:08 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
yched commentedPatch attached:
- hook_field_formatter() needs to do the
foreach ($items as $delta => $value)internally. Saves repeated function calls, and makes the hook consistent with field-type hooks like h_f_validate(), h_f_update(), ..., which all take $items and loop on it.- The distinction between 'single value' formatters and 'multiple values' formatters is gone. The formatter is free to return a render array with as many children it needs - one per value for typical formatters, one for all values for 'values in a table', or 'values as points in a graph'. We just require numeric keys.
From the patch:
- As a result,
'multiple values' => FIELD_BEHAVIOR_CUSTOMin hook_field_formatter_info() is gone, and so is the field_behaviors_formatter() function.- $delta param is removed from hook_field_formatter(). Also, the order of arguments is adjusted to match the common pattern for hook_field_[op]() hooks.
- Side optimization: do not run field.tpl.php if the formatter didn't return anything to display (for instance because the field is empty...)
Comment #2
moshe weitzman commentedI read through the patch and it looks like a nice simplication without the multiple values distinction.
Comment #3
sunAwesome, yched! One WTF less in Drupal! :)
Comment #4
dries commentedCommitted to CVS HEAD. Thanks!
Comment #5
effulgentsia commentedAwesome indeed. Subscribing to know when it lands, which I hope is soon.
Comment #6
effulgentsia commentedWell that was fast. Sorry for the x-post.