function AttachmentTestFormatter::viewElements
Overrides NumericUnformattedFormatter::viewElements
File
-
core/
modules/ views/ tests/ modules/ views_test_formatter/ src/ Plugin/ Field/ FieldFormatter/ AttachmentTestFormatter.php, line 27
Class
- AttachmentTestFormatter
- Plugin implementation of the 'number_unformatted_with_attachment' formatter.
Namespace
Drupal\views_test_formatter\Plugin\Field\FieldFormatterCode
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = parent::viewElements($items, $langcode);
// Add dummy attachments.
$entity_id = $items->getEntity()
->id();
$elements['#attached']['library'][] = 'foo/fake_library';
$elements['#attached']['drupalSettings']['AttachmentIntegerFormatter'][$entity_id] = $entity_id;
return $elements;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.