diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-11-12 02:59:30 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-11-12 02:59:30 +0000 |
commit | 566c39e7a30014af94a7e8b65dc5cdf5cfb3c6fb (patch) | |
tree | 1f81a91d627f81e8b1b859d33a6e3f9980d56e78 | |
parent | fd37414f45cf442b6fdc551c07da1b970ca04691 (diff) | |
download | brdo-566c39e7a30014af94a7e8b65dc5cdf5cfb3c6fb.tar.gz brdo-566c39e7a30014af94a7e8b65dc5cdf5cfb3c6fb.tar.bz2 |
- Patch #914792 by sun, moshe weitzman, effulgentsia: custom element properties entirely override default element info properties.
-rw-r--r-- | includes/common.inc | 18 | ||||
-rw-r--r-- | modules/field_ui/field_ui.admin.inc | 14 |
2 files changed, 23 insertions, 9 deletions
diff --git a/includes/common.inc b/includes/common.inc index 6018eb549..ef6d1b971 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -5754,6 +5754,9 @@ function element_sort_by_title($a, $b) { /** * Retrieve the default properties for the defined element type. + * + * @param $type + * An element type as defined by hook_element_info(). */ function element_info($type) { // Use the advanced drupal_static() pattern, since this is called very often. @@ -5776,6 +5779,21 @@ function element_info($type) { } /** + * Retrieve a single property for the defined element type. + * + * @param $type + * An element type as defined by hook_element_info(). + * @param $property_name + * The property within the element type that should be returned. + * @param $default + * (Optional) The value to return if the element type does not specify a + * value for the property. Defaults to NULL. + */ +function element_info_property($type, $property_name, $default = NULL) { + return (($info = element_info($type)) && array_key_exists($property_name, $info)) ? $info[$property_name] : $default; +} + +/** * Function used by uasort to sort structured arrays by weight, without the property weight prefix. */ function drupal_sort_weight($a, $b) { diff --git a/modules/field_ui/field_ui.admin.inc b/modules/field_ui/field_ui.admin.inc index de77b9175..9841add70 100644 --- a/modules/field_ui/field_ui.admin.inc +++ b/modules/field_ui/field_ui.admin.inc @@ -1745,13 +1745,7 @@ function field_ui_field_edit_form($form, &$form_state, $instance) { $bundles = field_info_bundles(); // Create a form structure for the instance values. - // @todo Fieldset element info needs to be merged in order to not skip the - // default element definition for #pre_render. While the current default - // value could simply be hard-coded, we'd possibly forget this location - // when system_element_info() is updated. See also form_builder(). This - // particular #pre_render, field_ui_field_edit_instance_pre_render(), might - // as well be entirely needless though. - $form['instance'] = array_merge(element_info('fieldset'), array( + $form['instance'] = array( '#tree' => TRUE, '#type' => 'fieldset', '#title' => t('%type settings', array('%type' => $bundles[$entity_type][$bundle]['label'])), @@ -1759,8 +1753,10 @@ function field_ui_field_edit_form($form, &$form_state, $instance) { '%field' => $instance['label'], '%type' => $bundles[$entity_type][$bundle]['label'], )), - '#pre_render' => array('field_ui_field_edit_instance_pre_render'), - )); + // Ensure field_ui_field_edit_instance_pre_render() gets called in addition + // to, not instead of, the #pre_render function(s) needed by all fieldsets. + '#pre_render' => array_merge(array('field_ui_field_edit_instance_pre_render'), element_info_property('fieldset', '#pre_render', array())), + ); // Build the non-configurable instance values. $form['instance']['field_name'] = array( |