You are here

protected function OptionsEmailItem::allowedValuesString in Contact Storage 8

Generates a string representation of an array of 'allowed values'.

This string format is suitable for edition in a textarea.

Parameters

array $values: An array of values, where array keys are values and array values are labels.

Return value

string The string representation of the $values array:

  • Values are separated by a carriage return.
  • Each value is in the format "value|label" or "value".

Overrides ListItemBase::allowedValuesString

File

src/Plugin/Field/FieldType/OptionsEmailItem.php, line 162

Class

OptionsEmailItem
Plugin to add the Option email item custom field type.

Namespace

Drupal\contact_storage\Plugin\Field\FieldType

Code

protected function allowedValuesString($values) {
  $lines = [];
  foreach ($values as $key => $value) {
    $lines[] = $key . '|' . $value['value'] . '|' . $value['emails'];
  }
  return implode("\n", $lines);
}