function field_test_field_formatter_settings_form

Implements hook_field_formatter_settings_form().

File

modules/field/tests/field_test.field.inc, line 294

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.