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) { ...@@ -728,6 +728,9 @@ function hook_field_is_empty($item, $field) {
* - FIELD_BEHAVIOR_DEFAULT: (default) If the widget accepts default * - FIELD_BEHAVIOR_DEFAULT: (default) If the widget accepts default
* values. * values.
* - FIELD_BEHAVIOR_NONE: if the widget does not support 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_info_alter()
* @see hook_field_widget_form() * @see hook_field_widget_form()
...@@ -737,7 +740,7 @@ function hook_field_is_empty($item, $field) { ...@@ -737,7 +740,7 @@ function hook_field_is_empty($item, $field) {
* @see hook_field_widget_settings_form() * @see hook_field_widget_settings_form()
*/ */
function hook_field_widget_info() { function hook_field_widget_info() {
return array( return array(
'text_textfield' => array( 'text_textfield' => array(
'label' => t('Text field'), 'label' => t('Text field'),
'field types' => array('text'), 'field types' => array('text'),
...@@ -764,6 +767,8 @@ function hook_field_widget_info() { ...@@ -764,6 +767,8 @@ function hook_field_widget_info() {
'multiple values' => FIELD_BEHAVIOR_DEFAULT, 'multiple values' => FIELD_BEHAVIOR_DEFAULT,
'default value' => 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() { ...@@ -49,8 +49,8 @@ function field_info_cache_clear() {
* the field type. * the field type.
* - 'widget types': Array of hook_field_widget_info() results, keyed by * - 'widget types': Array of hook_field_widget_info() results, keyed by
* widget_type. Each element has the following components: label, field * widget_type. Each element has the following components: label, field
* types, settings, and behaviors from hook_field_widget_info(), as well * types, settings, weight, and behaviors from hook_field_widget_info(),
* as module, giving the module that exposes the widget type. * as well as module, giving the module that exposes the widget type.
* - 'formatter types': Array of hook_field_formatter_info() results, keyed by * - 'formatter types': Array of hook_field_formatter_info() results, keyed by
* formatter_type. Each element has the following components: label, field * formatter_type. Each element has the following components: label, field
* types, and behaviors from hook_field_formatter_info(), as well as * types, and behaviors from hook_field_formatter_info(), as well as
...@@ -121,6 +121,7 @@ function _field_info_collate_types() { ...@@ -121,6 +121,7 @@ function _field_info_collate_types() {
} }
} }
drupal_alter('field_widget_info', $info['widget types']); drupal_alter('field_widget_info', $info['widget types']);
uasort($info['widget types'], 'drupal_sort_weight');
// Populate formatter types. // Populate formatter types.
foreach (module_implements('field_formatter_info') as $module) { 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