Skip to content

Instantly share code, notes, and snippets.

@wimleers
Created August 5, 2013 13:16
Show Gist options
  • Save wimleers/6155844 to your computer and use it in GitHub Desktop.
Save wimleers/6155844 to your computer and use it in GitHub Desktop.
After talking with @aspilicious, it seems this is what is necessary to support Display Suite in Drupal 8. Whenever Display Suite is used to render a "real field" differently, then `#field_name` should still be set. Whenever it is used to render a "pseudo field", then `#field_name` should not be set. Then no corresponding `data-edit-id` attribute…
core/modules/edit/edit.module | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/core/modules/edit/edit.module b/core/modules/edit/edit.module
index a7fbb5d..a174e4e 100644
--- a/core/modules/edit/edit.module
+++ b/core/modules/edit/edit.module
@@ -162,6 +162,11 @@ function edit_field_formatter_info_alter(&$info) {
* Implements hook_preprocess_HOOK() for field.tpl.php.
*/
function edit_preprocess_field(&$variables) {
+ // Drupal contrib may render "pseudo fields" that don't map to "real fields".
+ if (!isset($element['#field_name'])) {
+ return;
+ }
+
$element = $variables['element'];
$entity = $element['#object'];
$variables['attributes']['data-edit-id'] = $entity->entityType() . '/' . $entity->id() . '/' . $element['#field_name'] . '/' . $element['#language'] . '/' . $element['#view_mode'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment