public function EditableFieldsFieldFormatter::viewElements in Editable Fields 8
Same name and namespace in other branches
- 1.0.x src/Plugin/Field/FieldFormatter/EditableFieldsFieldFormatter.php \Drupal\editablefields\Plugin\Field\FieldFormatter\EditableFieldsFieldFormatter::viewElements()
Builds a renderable array for a field value.
Parameters
\Drupal\Core\Field\FieldItemListInterface $items: The field values to be rendered.
string $langcode: The language that should be used to render the field.
Return value
array A renderable array for $items, as an array of child elements keyed by consecutive numeric indexes starting from 0.
Overrides FormatterInterface::viewElements
File
- src/
Plugin/ Field/ FieldFormatter/ EditableFieldsFieldFormatter.php, line 104
Class
- EditableFieldsFieldFormatter
- Plugin implementation of the 'editablefields_formatter' formatter.
Namespace
Drupal\editablefields\Plugin\Field\FieldFormatterCode
public function viewElements(FieldItemListInterface $items, $langcode) {
/** @var \Drupal\Core\Entity\EntityInterface $entity */
$entity = $items
->getEntity();
if (!$this->editablefieldsHelper
->checkAccess($entity)) {
return [];
}
return [
$this->editablefieldsHelper
->getForm($entity, $this->fieldDefinition
->getName(), $this
->getSetting('form_mode')),
];
}