1 field_ui.api.php hook_field_widget_settings_form($field, $instance)

Add settings to a widget settings form.

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

Parameters

$field: The field structure being configured.

$instance: The instance structure being configured.

Return value

The form definition for the widget settings.

Related topics

File

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

Code

function hook_field_widget_settings_form($field, $instance) {
  $widget = $instance['widget'];
  $settings = $widget['settings'];

  if ($widget['type'] == 'text_textfield') {
    $form['size'] = array(
      '#type' => 'number',
      '#title' => t('Size of textfield'),
      '#default_value' => $settings['size'],
      '#min' => 1,
      '#required' => TRUE,
    );
  }
  else {
    $form['rows'] = array(
      '#type' => 'number',
      '#title' => t('Rows'),
      '#default_value' => $settings['rows'],
      '#min' => 1,
      '#required' => TRUE,
    );
  }

  return $form;
}