function options_allowed_values_string

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

This string format is suitable for edition in a textarea.

Parameters

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

Return value

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 options_allowed_values_string()
options_field_settings_form in drupal/core/modules/field/modules/options/options.module
Implements hook_field_settings_form().

File

drupal/core/modules/field/modules/options/options.module, line 361
Defines selection, check box and radio button widgets for text and numeric fields.

Code

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