function field_ui_widget_type_options

Returns an array of widget type options for a field type.

If no field type is provided, returns a nested array of all widget types, keyed by field type human name.

5 calls to field_ui_widget_type_options()
FieldOverview::form in drupal/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php
Overrides Drupal\field_ui\OverviewBase::form().
FieldOverview::validateAddExisting in drupal/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php
Validates the 're-use existing field' row.
FieldOverview::validateAddNew in drupal/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php
Validates the 'add new field' row.
field_ui_field_type_options in drupal/core/modules/field_ui/field_ui.admin.inc
Returns an array of field_type options.
field_ui_widget_type_form in drupal/core/modules/field_ui/field_ui.admin.inc
Form constructor for the widget selection form.

File

drupal/core/modules/field_ui/field_ui.admin.inc, line 449
Administrative interface for custom field type creation.

Code

function field_ui_widget_type_options($field_type = NULL, $by_label = FALSE) {
  $options =& drupal_static(__FUNCTION__);
  if (!isset($options)) {
    $options = array();
    $field_types = field_info_field_types();
    $widget_types = field_info_widget_types();
    uasort($widget_types, 'drupal_sort_weight');
    foreach ($widget_types as $name => $widget_type) {
      foreach ($widget_type['field_types'] as $widget_field_type) {

        // Check that the field type exists.
        if (isset($field_types[$widget_field_type])) {
          $options[$widget_field_type][$name] = $widget_type['label'];
        }
      }
    }
  }
  if (isset($field_type)) {
    return !empty($options[$field_type]) ? $options[$field_type] : array();
  }
  if ($by_label) {
    $field_types = field_info_field_types();
    $options_by_label = array();
    foreach ($options as $field_type => $widgets) {
      $options_by_label[$field_types[$field_type]['label']] = $widgets;
    }
    return $options_by_label;
  }
  return $options;
}