You are here

protected function DoubleField::allowedValuesString in Double Field 4.x

Same name and namespace in other branches
  1. 8.3 src/Plugin/Field/FieldType/DoubleField.php \Drupal\double_field\Plugin\Field\FieldType\DoubleField::allowedValuesString()

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".
1 call to DoubleField::allowedValuesString()
DoubleField::fieldSettingsForm in src/Plugin/Field/FieldType/DoubleField.php
Returns a form for the field-level settings.

File

src/Plugin/Field/FieldType/DoubleField.php, line 566

Class

DoubleField
Plugin implementation of the 'double_field' field type.

Namespace

Drupal\double_field\Plugin\Field\FieldType

Code

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