You are here

public static function YamlFormOptions::convertOptionsToValues in YAML Form 8

Convert options to values for yamform_multiple element.

Parameters

array $options: An array of options.

Return value

array An array of values.

2 calls to YamlFormOptions::convertOptionsToValues()
YamlFormOptions::processYamlFormOptions in src/Element/YamlFormOptions.php
Process options and build options widget.
YamlFormOptions::valueCallback in src/Element/YamlFormOptions.php
Determines how user input is mapped to an element's #value property.

File

src/Element/YamlFormOptions.php, line 182

Class

YamlFormOptions
Provides a form element to assist in creation of options.

Namespace

Drupal\yamlform\Element

Code

public static function convertOptionsToValues(array $options = []) {
  $values = [];
  foreach ($options as $value => $text) {
    $values[] = [
      'value' => $value,
      'text' => $text,
    ];
  }
  return $values;
}