You are here

protected function WebformAddressLoqate::getValueFromOptions in Loqate 8

Same name and namespace in other branches
  1. 2.x modules/pca_webform/src/Plugin/WebformElement/WebformAddressLoqate.php \Drupal\pca_webform\Plugin\WebformElement\WebformAddressLoqate::getValueFromOptions()

Helper function to return the human readable value of a possible select.

Parameters

$field: The field key.

$composite_elements: The composite element array.

$values: The saved values array

Return value

string The human readable value of the field.

1 call to WebformAddressLoqate::getValueFromOptions()
WebformAddressLoqate::formatTextItemValue in modules/pca_webform/src/Plugin/WebformElement/WebformAddressLoqate.php
Format composite element value into lines of text.

File

modules/pca_webform/src/Plugin/WebformElement/WebformAddressLoqate.php, line 103

Class

WebformAddressLoqate
Provides an 'address' element.

Namespace

Drupal\pca_webform\Plugin\WebformElement

Code

protected function getValueFromOptions($field, $composite_elements, $values) {
  $value = $values[$field];
  $field = $composite_elements[$field];
  $type = $field['#type'];
  $option_value = $type === 'select' ? $field['#options'][$value] : $value;
  if ($option_value instanceof TranslatableMarkup) {
    $option_value = (string) $option_value;
  }
  return $option_value;
}