You are here

function field_example_field_formatter_info in Examples for Developers 7

Implements hook_field_formatter_info().

We need to tell Drupal that we have two different types of formatters for this field. One will change the text color, and the other will change the background color.

See also

field_example_field_formatter_view()

Related topics

File

field_example/field_example.module, line 113
An example field using the Field Types API.

Code

function field_example_field_formatter_info() {
  return array(
    // This formatter just displays the hex value in the color indicated.
    'field_example_simple_text' => array(
      'label' => t('Simple text-based formatter'),
      'field types' => array(
        'field_example_rgb',
      ),
    ),
    // This formatter changes the background color of the content region.
    'field_example_color_background' => array(
      'label' => t('Change the background of the output text'),
      'field types' => array(
        'field_example_rgb',
      ),
    ),
  );
}