Quick Edit API

Last updated on
9 January 2017

The Quick Edit API is new in Drupal 8. It 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
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