Commit bfc2352b authored by catch's avatar catch
Browse files

Issue #1586356 by dww: Fixed Missing 'weight' support from...

Issue #1586356 by dww: Fixed Missing 'weight' support from hook_field_widget_info() makes it impossible to sanely order widgets.
parent aa9744b1
......@@ -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()
......@@ -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,
),
);
}
......
......@@ -49,8 +49,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
......@@ -121,6 +121,7 @@ function _field_info_collate_types() {
}
}
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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment