Advertising sustains the DA. Ads are hidden for members. Join today

Quick Edit API

Last updated on
10 September 2022

This page has not yet been reviewed by Quick Edit maintainer(s) and added to the menu.

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
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() and hook_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

Tags

Help improve this page

Page status: No known problems

You can: