7.x field_ui.api.php hook_field_instance_settings_form($field, $instance)

Add settings to an instance field settings form.

Invoked from field_ui_field_edit_form() to allow the module defining the field to add settings for a field instance.

Parameters

$field: The field structure being configured.

$instance: The instance structure being configured.

Return value

The form definition for the field instance settings.

Related topics

5 functions implement hook_field_instance_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_instance_settings_form in modules/field/tests/field_test.field.inc
Implements hook_field_instance_settings_form().
file_field_instance_settings_form in modules/file/file.field.inc
Implements hook_field_instance_settings_form().
image_field_instance_settings_form in modules/image/image.field.inc
Implements hook_field_instance_settings_form().
number_field_instance_settings_form in modules/field/modules/number/number.module
Implements hook_field_instance_settings_form().
text_field_instance_settings_form in modules/field/modules/text/text.module
Implements hook_field_instance_settings_form().

File

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

Code

function hook_field_instance_settings_form($field, $instance) {
  $settings = $instance['settings'];
  $form['text_processing'] = array(
    '#type' => 'radios',
    '#title' => t('Text processing'),
    '#default_value' => $settings['text_processing'],
    '#options' => array(
      t('Plain text'),
      t('Filtered text (user selects text format)'),
    ),
  );
  if ($field['type'] == 'text_with_summary') {
    $form['display_summary'] = array(
      '#type' => 'select',
      '#title' => t('Display summary'),
      '#options' => array(
        t('No'),
        t('Yes'),
      ),
      '#description' => t('Display the summary to allow the user to input a summary value. Hide the summary to automatically fill it with a trimmed portion from the main post.'),
      '#default_value' => !empty($settings['display_summary']) ? $settings['display_summary'] : 0,
    );
  }
  return $form;
}

Comments

inventlogic’s picture

Spent ages trying to get the text processing array to show up on the field settings for a custom field.

Added this hook to the custom module and voila the text processing appears.

I think the documentation needs to be updated on the following hooks to mention this:

hook_field_info
hook_field_formatter_info_alter
hook_field_widget_info_alter
hook_field_is_empty
hook_field_instance_settings_form
hook_field_formatter_info
hook_field_formatter_view