You are here

public function DropdownFieldFormatter::getLabelForValue in Open Social 8.6

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::getLabelForValue()
  2. 8 modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::getLabelForValue()
  3. 8.2 modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::getLabelForValue()
  4. 8.3 modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::getLabelForValue()
  5. 8.4 modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::getLabelForValue()
  6. 8.5 modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::getLabelForValue()
  7. 8.7 modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::getLabelForValue()
  8. 8.8 modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::getLabelForValue()
  9. 10.3.x modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::getLabelForValue()
  10. 10.0.x modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::getLabelForValue()
  11. 10.1.x modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::getLabelForValue()
  12. 10.2.x modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php \Drupal\dropdown\Plugin\Field\FieldFormatter\DropdownFieldFormatter::getLabelForValue()

Display dropdown labels.

1 call to DropdownFieldFormatter::getLabelForValue()
DropdownFieldFormatter::viewValue in modules/custom/dropdown/src/Plugin/Field/FieldFormatter/DropdownFieldFormatter.php
Generate the output appropriate for one field item.

File

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

Class

DropdownFieldFormatter
Plugin implementation of the 'dropdown_field_formatter' formatter.

Namespace

Drupal\dropdown\Plugin\Field\FieldFormatter

Code

public function getLabelForValue($value) {
  $settings = $this
    ->getFieldSettings();
  $allowed_values = $settings['allowed_values'];
  foreach ($allowed_values as $allowed_value) {
    if (isset($allowed_value['value']) && $allowed_value['value'] === $value) {
      $label = $allowed_value['label'];
      return Html::escape($label);
    }
  }
}