public function EntityDefaultUIController::hook_forms in Entity API 7
Provides definitions for implementing hook_forms().
Use per bundle form ids if possible, such that easy per bundle alterations are supported too.
Note that for performance reasons, this method is invoked only for forms which receive the entity_type as first argument. Thus any forms added must follow that pattern.
See also
File
- includes/
entity.ui.inc, line 136 - Provides a controller for building an entity overview form.
Class
- EntityDefaultUIController
- Default UI controller providing admin UI.
Code
public function hook_forms() {
// The overview and the operation form are implemented by the controller,
// the callback and validation + submit handlers just invoke the controller.
$forms[$this->entityType . '_overview_form'] = array(
'callback' => 'entity_ui_overview_form',
'wrapper_callback' => 'entity_ui_form_defaults',
);
$forms[$this->entityType . '_operation_form'] = array(
'callback' => 'entity_ui_operation_form',
'wrapper_callback' => 'entity_ui_form_defaults',
);
// The entity form (ENTITY_TYPE_form) handles editing, adding and cloning.
// For that form, the wrapper callback entity_ui_main_form_defaults() gets
// directly invoked via entity_ui_get_form().
// If there are bundles though, we use form ids that include the bundle name
// (ENTITY_TYPE_edit_BUNDLE_NAME_form) to enable per bundle alterations
// as well as alterations based upon the base form id (ENTITY_TYPE_form).
if (!(count($this->entityInfo['bundles']) == 1 && isset($this->entityInfo['bundles'][$this->entityType]))) {
foreach ($this->entityInfo['bundles'] as $bundle => $bundle_info) {
$forms[$this->entityType . '_edit_' . $bundle . '_form']['callback'] = $this->entityType . '_form';
// Again the wrapper callback is invoked by entity_ui_get_form() anyway.
}
}
return $forms;
}