Same name and namespace in other branches
- 8.x-2.x src/Plugin/Field/FieldWidget/ExifReadonlyWidget.php \Drupal\exif\Plugin\Field\FieldWidget\ExifReadonlyWidget::formElement() 1 comment
File
-
src/
Plugin/ Field/ FieldWidget/ ExifReadonlyWidget.php, line 80
Class
- ExifReadonlyWidget
- Plugin implementation of the 'exif_readonly' widget.
Namespace
Drupal\exif\Plugin\Field\FieldWidgetCode
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$value = $items->getValue();
$entity_type = $items->getFieldDefinition()
->getTargetEntityTypeId();
$access = $this->entityTypeManager
->getAccessControlHandler($entity_type)
->fieldAccess('view', $items->getFieldDefinition());
if (!$access) {
$element += [
'#type' => '#hidden',
'#value' => '',
];
}
$element += $items->view();
$element += [
'#value' => $value,
'#default_value' => $value,
];
return $element;
}