You are here

function hook_field_formatter_settings_form in Drupal 7

Specify the form elements for a formatter's settings.

This hook is only invoked if hook_field_formatter_settings_summary() returns a non-empty value.

Parameters

$field: The field structure being configured.

$instance: The instance structure being configured.

$view_mode: The view mode being configured.

$form: The (entire) configuration form array, which will usually have no use here.

$form_state: The form state of the (entire) configuration form.

Return value

The form elements for the formatter settings.

Related topics

4 functions implement hook_field_formatter_settings_form()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

field_test_field_formatter_settings_form in modules/field/tests/field_test.field.inc
Implements hook_field_formatter_settings_form().
image_field_formatter_settings_form in modules/image/image.field.inc
Implements hook_field_formatter_settings_form().
number_field_formatter_settings_form in modules/field/modules/number/number.module
Implements hook_field_formatter_settings_form().
text_field_formatter_settings_form in modules/field/modules/text/text.module
Implements hook_field_formatter_settings_form().

File

modules/field_ui/field_ui.api.php, line 154
Hooks provided by the Field UI module.

Code

function hook_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $element = array();
  if ($display['type'] == 'text_trimmed' || $display['type'] == 'text_summary_or_trimmed') {
    $element['trim_length'] = array(
      '#title' => t('Length'),
      '#type' => 'textfield',
      '#size' => 20,
      '#default_value' => $settings['trim_length'],
      '#element_validate' => array(
        'element_validate_integer_positive',
      ),
      '#required' => TRUE,
    );
  }
  return $element;
}