diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-07-30 19:35:47 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-07-30 19:35:47 +0000 |
commit | eb34d29999f0f0c4f36201cb01be9f936f9a1fc1 (patch) | |
tree | 56385b76aadc0ba7c7578899e5f55ecd1fe9de29 | |
parent | 6ef2ddae21279e50db21fb816442470b449cd1d1 (diff) | |
download | brdo-eb34d29999f0f0c4f36201cb01be9f936f9a1fc1.tar.gz brdo-eb34d29999f0f0c4f36201cb01be9f936f9a1fc1.tar.bz2 |
- Patch #534318 by yched: better defaults and corrected documentation.
-rw-r--r-- | modules/field/field.api.php | 12 | ||||
-rw-r--r-- | modules/field/field.info.inc | 13 |
2 files changed, 22 insertions, 3 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php index 425786093..c6d80db86 100644 --- a/modules/field/field.api.php +++ b/modules/field/field.api.php @@ -171,7 +171,9 @@ function hook_field_info() { function hook_field_info_alter(&$info) { // Add a setting to all field types. foreach ($info as $field_type => $field_type_info) { - $info[$field_type]['settings'][] = array('mymodule_additional_setting' => 'default value'); + $info[$field_type]['settings'] += array( + 'mymodule_additional_setting' => 'default value', + ); } // Change the default widget for fields of type 'foo'. @@ -261,7 +263,9 @@ function hook_field_widget_info() { */ function hook_field_widget_info_alter(&$info) { // Add a setting to a widget type. - $info['text_textfield']['settings'][] = array('mymodule_additional_setting' => 'default value'); + $info['text_textfield']['settings'] += array( + 'mymodule_additional_setting' => 'default value', + ); // Let a new field type re-use an existing widget. $info['options_select']['field types'][] = 'my_field_type'; @@ -290,7 +294,9 @@ function hook_field_formatter_info() { */ function hook_field_formatter_info_alter(&$info) { // Add a setting to a formatter type. - $info['text_default']['settings'][] = array('mymodule_additional_setting' => 'default value'); + $info['text_default']['settings'] += array( + 'mymodule_additional_setting' => 'default value', + ); // Let a new field type re-use an existing formatter. $info['text_default']['field types'][] = 'my_field_type'; diff --git a/modules/field/field.info.inc b/modules/field/field.info.inc index e9ac66c23..abe72197a 100644 --- a/modules/field/field.info.inc +++ b/modules/field/field.info.inc @@ -94,6 +94,11 @@ function _field_info_collate_types($reset = FALSE) { foreach (module_implements('field_info') as $module) { $field_types = (array) module_invoke($module, 'field_info'); foreach ($field_types as $name => $field_info) { + // Provide defaults. + $field_info += array( + 'settings' => array(), + 'instance_settings' => array(), + ); $info['field types'][$name] = $field_info; $info['field types'][$name]['module'] = $module; } @@ -104,6 +109,10 @@ function _field_info_collate_types($reset = FALSE) { foreach (module_implements('field_widget_info') as $module) { $widget_types = (array) module_invoke($module, 'field_widget_info'); foreach ($widget_types as $name => $widget_info) { + // Provide defaults. + $widget_info += array( + 'settings' => array(), + ); $info['widget types'][$name] = $widget_info; $info['widget types'][$name]['module'] = $module; } @@ -114,6 +123,10 @@ function _field_info_collate_types($reset = FALSE) { foreach (module_implements('field_formatter_info') as $module) { $formatter_types = (array) module_invoke($module, 'field_formatter_info'); foreach ($formatter_types as $name => $formatter_info) { + // Provide defaults. + $formatter_info += array( + 'settings' => array(), + ); $info['formatter types'][$name] = $formatter_info; $info['formatter types'][$name]['module'] = $module; } |