diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2012-09-04 14:05:50 -0700 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2012-09-04 14:12:38 -0700 |
commit | 5db3dd49ac4cc183eacc1e7da01c91f0aa47cd2b (patch) | |
tree | 79f583e79e1057f07531858ea0146366ca960119 /modules/field | |
parent | c48394d85ffbe682713579af2b3c8740c0a34f35 (diff) | |
download | brdo-5db3dd49ac4cc183eacc1e7da01c91f0aa47cd2b.tar.gz brdo-5db3dd49ac4cc183eacc1e7da01c91f0aa47cd2b.tar.bz2 |
Issue #1586356 by dww, amateescu: Fixed Missing 'weight' support from hook_field_widget_info() makes it impossible to sanely order widgets.
Diffstat (limited to 'modules/field')
-rw-r--r-- | modules/field/field.api.php | 7 | ||||
-rw-r--r-- | modules/field/field.info.inc | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php index 73787b00d..041122bfe 100644 --- a/modules/field/field.api.php +++ b/modules/field/field.api.php @@ -728,6 +728,9 @@ function hook_field_is_empty($item, $field) { * - FIELD_BEHAVIOR_DEFAULT: (default) If the widget accepts default * values. * - FIELD_BEHAVIOR_NONE: if the widget does not support default values. + * - weight: (optional) An integer to determine the weight of this widget + * relative to other widgets in the Field UI when selecting a widget for a + * given field instance. * * @see hook_field_widget_info_alter() * @see hook_field_widget_form() @@ -737,7 +740,7 @@ function hook_field_is_empty($item, $field) { * @see hook_field_widget_settings_form() */ function hook_field_widget_info() { - return array( + return array( 'text_textfield' => array( 'label' => t('Text field'), 'field types' => array('text'), @@ -764,6 +767,8 @@ function hook_field_widget_info() { 'multiple values' => FIELD_BEHAVIOR_DEFAULT, 'default value' => FIELD_BEHAVIOR_DEFAULT, ), + // As an advanced widget, force it to sink to the bottom of the choices. + 'weight' => 2, ), ); } diff --git a/modules/field/field.info.inc b/modules/field/field.info.inc index 52d1581e5..9e7ab938d 100644 --- a/modules/field/field.info.inc +++ b/modules/field/field.info.inc @@ -54,8 +54,8 @@ function field_info_cache_clear() { * the field type. * - 'widget types': Array of hook_field_widget_info() results, keyed by * widget_type. Each element has the following components: label, field - * types, settings, and behaviors from hook_field_widget_info(), as well - * as module, giving the module that exposes the widget type. + * types, settings, weight, and behaviors from hook_field_widget_info(), + * as well as module, giving the module that exposes the widget type. * - 'formatter types': Array of hook_field_formatter_info() results, keyed by * formatter_type. Each element has the following components: label, field * types, and behaviors from hook_field_formatter_info(), as well as @@ -124,6 +124,7 @@ function _field_info_collate_types($reset = FALSE) { } } drupal_alter('field_widget_info', $info['widget types']); + uasort($info['widget types'], 'drupal_sort_weight'); // Populate formatter types. foreach (module_implements('field_formatter_info') as $module) { |