You are here

public function DropdownFieldFormatter::viewElements in Open Social 8.4

Same name and namespace in other branches
  1. 8.9 modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::viewElements()
  2. 8 modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::viewElements()
  3. 8.2 modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::viewElements()
  4. 8.3 modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::viewElements()
  5. 8.5 modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::viewElements()
  6. 8.6 modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::viewElements()
  7. 8.7 modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::viewElements()
  8. 8.8 modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::viewElements()
  9. 10.3.x modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::viewElements()
  10. 10.0.x modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::viewElements()
  11. 10.1.x modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::viewElements()
  12. 10.2.x modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::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

modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php, line 26

Class

DropdownFieldFormatter
Plugin implementation of the 'dropdown_field_formatter' formatter.

Namespace

Drupal\dropdown\Plugin\Field\FieldFormatter

Code

public function viewElements(FieldItemListInterface $items, $langcode) {
  $elements = [];
  foreach ($items as $delta => $item) {
    $elements[$delta] = [
      '#markup' => $this
        ->viewValue($item),
    ];
  }
  return $elements;
}