diff options
Diffstat (limited to 'modules/field/field.api.php')
-rw-r--r-- | modules/field/field.api.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php index 39618ea08..f8d2137d9 100644 --- a/modules/field/field.api.php +++ b/modules/field/field.api.php @@ -101,6 +101,63 @@ function hook_fieldable_info_alter(&$info) { } /** + * Expose "pseudo-field" components on fieldable objects. + * + * Field UI's 'Manage fields' page lets users re-order fields, but also + * non-field components. For nodes, that would be title, menu settings, or + * other elements exposed by contributed modules through hook_form() or + * hook_form_alter(). + * + * Fieldable entities or contributed modules that want to have their components + * supported should expose them using this hook, and use + * field_attach_extra_weight() to retrieve the user-defined weight when + * inserting the component. + * + * @param $bundle + * The name of the bundle being considered. + * @return + * An array of 'pseudo-field' components. The keys are the name of the element + * as it appears in the form structure. The values are arrays with the + * following key/value pairs: + * - label: The human readable name of the component. + * - description: A short description of the component contents. + * - weight: The default weight of the element. + * - view: (optional) The name of the element as it appears in the rendered + * structure, if different from the name in the form. + */ +function hook_field_extra_fields($bundle) { + $extra = array(); + + if ($type = node_type_get_type($bundle)) { + if ($type->has_title) { + $extra['title'] = array( + 'label' => $type->title_label, + 'description' => t('Node module element.'), + 'weight' => -5, + ); + } + if ($bundle == 'poll' && module_exists('poll')) { + $extra['title'] = array( + 'label' => t('Poll title'), + 'description' => t('Poll module title.'), + 'weight' => -5, + ); + $extra['choice_wrapper'] = array( + 'label' => t('Poll choices'), + 'description' => t('Poll module choices.'), + 'weight' => -4, + ); + $extra['settings'] = array( + 'label' => t('Poll settings'), + 'description' => t('Poll module settings.'), + 'weight' => -3, + ); + } + } + return $extra; +} + +/** * @} End of "ingroup field_fieldable_type" */ |