You are here

function field_test_field_formatter_settings_form in Drupal 7

Implements hook_field_formatter_settings_form().

File

modules/field/tests/field_test.field.inc, line 294
Defines a field type and its formatters and widgets.

Code

function field_test_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $element = array();

  // The name of the setting depends on the formatter type.
  $map = array(
    'field_test_default' => 'test_formatter_setting',
    'field_test_multiple' => 'test_formatter_setting_multiple',
    'field_test_with_prepare_view' => 'test_formatter_setting_additional',
  );
  if (isset($map[$display['type']])) {
    $name = $map[$display['type']];
    $element[$name] = array(
      '#title' => t('Setting'),
      '#type' => 'textfield',
      '#size' => 20,
      '#default_value' => $settings[$name],
      '#required' => TRUE,
    );
  }
  return $element;
}