Hi All,

I've been messing with this for a while and can't seem to get this working. I'm using the Field Collection module and print_r($variables['#items']) in the preview outputs the following.

Array
(
    [0] => Array
        (
            [value] => 12
        )

)

I'm trying to place each field collection in an HTML UL. I was going to try using theme_item_list() but can't figure out how to get to the actual values in my field collection instead of just the ID of the field collection (12).

Does anyone have an example of how to use a custom formatter with field collections?

Thanks for reading,
-Tim

Comments

deciphered’s picture

Status: Active » Fixed

You'll need to load the Field Collection data from the ID:

field_collection_item_load($item_id);

Custom Formatters can only provide you with the data that the fields provide it with, which in this case is simply the ID.

TimG1’s picture

Excellent, didn't know about field_collection_item_load(). Thanks Deciphered!

-Tim

Status: Fixed » Closed (fixed)

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