Community Documentation

Entity Operations

Last updated April 14, 2013. Created by joachim on February 17, 2013.
Log in to edit this page.

The Entity Operations module is a system to allow fast building of UIs for custom entity types, with very little code. It allows for basic operations such as 'view', 'edit', 'delete', while being extensible to allow any kind of custom operation.

For an entity which only needs to use a basic form, this means that only 3 functions are required to define the entity type: hook_schema() for its table, hook_entity_info(), and the entity access callback.

Furthermore, operations are exposed to a variety of other systems:

  • Operations are available as fields to Views, as links to the operation tab (for example, 'view', 'edit', 'delete' links on a list of entities).
  • Operations that behave as actions can be added to a view using Views Bulk Operations, to act on multiple entities at once.
  • Operations that behave as actions are exposed to Services as targeted actions on entities
  • Operations that provide forms can be shown as forms on the entity view page

Overview

Entity Operations provides a UI modelled on the way nodes work:

  • The various paths for working with nodes have a common base, 'node'
  • An individual node can be viewed at 'node/ID'
  • Further operations and tasks on the node can be viewed at paths such as 'node/ID/edit', 'node/ID/delete' and so on.

For your custom entity this works the same:

  • Define the common base path, eg, 'myentity'
  • Define operations on the entity, such as 'view', 'edit', 'delete'. These then form paths at 'myentity/ID/view', 'myentity/ID/edit' and so on
  • Define one operation to be the default, which is then output for 'myentity/ID'. This will usually be 'view'.

Page status

About this page

Drupal version
Drupal 7.x
Audience
Programmers
Level
Advanced

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.