public static function YamlFormOptions::convertValuesToOptions in YAML Form 8
Convert values from yamform_multiple element to options.
Parameters
array $values: An array of values.
Return value
array An array of options.
2 calls to YamlFormOptions::convertValuesToOptions()
- YamlFormOptions::validateYamlFormOptions in src/
Element/ YamlFormOptions.php - Validates form options element.
- YamlFormUiOptionsForm::copyFormValuesToEntity in modules/
yamlform_ui/ src/ YamlFormUiOptionsForm.php - Copies top-level form values to entity properties
File
- src/
Element/ YamlFormOptions.php, line 154
Class
- YamlFormOptions
- Provides a form element to assist in creation of options.
Namespace
Drupal\yamlform\ElementCode
public static function convertValuesToOptions(array $values = []) {
$options = [];
foreach ($values as $value) {
$option_value = $value['value'];
$option_text = $value['text'];
// Populate empty option value or option text.
if ($option_value === '') {
$option_value = $option_text;
}
elseif ($option_text === '') {
$option_text = $option_value;
}
$options[$option_value] = $option_text;
}
return $options;
}