Quick support question:

I just want my custom formatter to wrap some html around the field that is formatted.
How do i do that?

To be specific: what is the name of the "field variable" to use inside the custom formatter?
My formatter looks like this:

<some-wrapper-div> 
    [field-variable] 
</div>

Is that even possible?

Thanks in advance,
Frank

Comments

Knarf31’s picture

I'm wondering if this is really this complicated or if my question is just lousy :-)

I'm trying to achieve the following:

I want to be able to format a textfield with a custom formatter.
This custom formatter only wraps a div around the fields content.

In order to do this i need a "variable" or a "token" inside my custom formatter, which represents the fields value.
Is this possible or do i have to do this in php?

Can someone help me out here?

Knarf31’s picture

Status: Active » Fixed

Just in case anyone is interested in this too.
I got time to talk about this with someone more experienced than me and we got the following code which is working fine for me:

//outer wrapper
$output ='<div class="outer-wrapper">';

//do the following for each field instance
foreach ($variables['#items'] as $item) { 

//inner-wrapper
$output .= '<div id="inner-wrapper">

//output field value
$output .= $item['value'];

//close inner-wrapper
$output .='</div>';
}

//close outer-wrapper
$output ='</div>';

//output everything
return $output;

Status: Fixed » Closed (fixed)

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