On this page
Quick Edit API
The Quick Edit API is inspired, and in some parts functionally identical to the Drupal 7 Quick Edit module.
For high-level information on what this module does, see the Quick Edit module documentation.
API features
Ordered by most to least frequently used APIs:
- In-place editor plugins
\Drupal\quickedit\Plugin\InPlaceEditorInterface
: in-place editor plugins, to provide additional in-place editors (i.e. optimized for certain fields, for example for images, dates …) to improve the in-place editing experience- Plugin implementations must be annotated with the
@InPlaceEditor
annotation so they can be discovered. \Drupal\quickedit\Plugin\InPlaceEditorBase
provides a default implementation so text editor plugins don't need to implement every method
- Plugin implementations must be annotated with the
- Access control
- Quick Edit doesn't have its own access control — for that, use the Entity Access API. Note that you can alter this with hooks like
hook_entity_access()
andhook_entity_field_access()
, for entities and fields, respectively. - Custom render pipeline
- Sometimes, entities/fields are rendered not using the default Entity/Field API render pipeline, which uses entity view modes, field formatters, et cetera. In those cases where a custom render pipeline is used, and you still want to make it possible to do in-place editing, implement
hook_quickedit_render_field()
. For details, see the documentation there. This is something you will need to do only in the most esoteric modules: providing a custom render pipeline is a very, very rare case.
Client-side caching of metadata
In order to function, Quick Edit needs quite a bit of metadata. For every field, it needs to know the label, which in-place editor to use, whether the current user is allowed to edit a field and potentially custom metadata specific to the in-place editor to use.
That metadata needs to be retrieved from the server (i.e. Drupal), but doing so on every page load would be wasteful and slow. That's why Quick Edit caches this information on the client-side. It caches this in sessionStorage
, which means that merely closing and reopening the browser tab will already clear this cache. This prevents this cache from growing too large. It's also invalidated automatically when the current user's permissions change.
While developing new in-place editor plugins for Quick Edit, you'll want to clear sessionStorage
, or at least the key-value pairs stored in it whose keys have the Drupal.quickedit.metadata.
prefix.
See also
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion