Plugin implementation of the 'list_key' formatter.
@FieldFormatter(
id = "list_key",
module = "options",
label = @Translation("Key"),
field_types = {
"list_integer",
"list_float",
"list_text",
"list_boolean"
}
)
Expanded class hierarchy of OptionsKeyFormatter
class OptionsKeyFormatter extends FormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(EntityInterface $entity, $langcode, array $items) {
$elements = array();
foreach ($items as $delta => $item) {
$elements[$delta] = array(
'#markup' => field_filter_xss($item['value']),
);
}
return $elements;
}
}