field_ui_widget_type_form

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 field_ui_widget_type_form($form, &$form_state, $instance)

Menu callback; select a widget for the field.

Code

modules/field_ui/field_ui.admin.inc, line 1608

<?php
function field_ui_widget_type_form($form, &$form_state, $instance) {
  drupal_set_title($instance['label']);

  $bundle = $instance['bundle'];
  $entity_type = $instance['entity_type'];
  $field_name = $instance['field_name'];

  $field = field_info_field($field_name);
  $field_type = field_info_field_types($field['type']);
  $widget_type = field_info_widget_types($instance['widget']['type']);
  $bundles = field_info_bundles();
  $bundle_label = $bundles[$entity_type][$bundle]['label'];

  $form = array(
    '#bundle' => $bundle, 
    '#entity_type' => $entity_type, 
    '#field_name' => $field_name,
  );

  $form['basic'] = array(
    '#type' => 'fieldset', 
    '#title' => t('Change widget'),
  );
  $form['basic']['widget_type'] = array(
    '#type' => 'select', 
    '#title' => t('Widget type'), 
    '#required' => TRUE, 
    '#options' => field_ui_widget_type_options($field['type']), 
    '#default_value' => $instance['widget']['type'], 
    '#description' => t('The type of form element you would like to present to the user when creating this field in the %type type.', array('%type' => $bundle_label)),
  );

  $form['actions'] = array('#type' => 'actions');
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Continue'),
  );

  $form['#validate'] = array();
  $form['#submit'] = array('field_ui_widget_type_form_submit');

  return $form;
}
?>