quickedit_preprocess_field(&$variables)
Implements hook_preprocess_HOOK() for field templates.
File
- core/modules/quickedit/quickedit.module, line 126
- Provides in-place content editing functionality for fields.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | function quickedit_preprocess_field(& $variables ) { $variables [ '#cache' ][ 'contexts' ][] = 'user.permissions' ; if (!\Drupal::currentUser()->hasPermission( 'access in-place editing' )) { return ; } $element = $variables [ 'element' ]; /** @var $entity \Drupal\Core\Entity\EntityInterface */ $entity = $element [ '#object' ]; // Quick Edit module only supports view modes, not dynamically defined // "display options" (which \Drupal\Core\Field\FieldItemListInterface::view() // always names the "_custom" view mode). // @see \Drupal\Core\Field\FieldItemListInterface::view() if ( $element [ '#view_mode' ] === '_custom' ) { return ; } // Fields that are computed fields are not editable. $definition = $entity ->getFieldDefinition( $element [ '#field_name' ]); if (! $definition ->isComputed()) { $variables [ 'attributes' ][ 'data-quickedit-field-id' ] = $entity ->getEntityTypeId() . '/' . $entity ->id() . '/' . $element [ '#field_name' ] . '/' . $element [ '#language' ] . '/' . $element [ '#view_mode' ]; } } |
Please login to continue.