public static function YamlFormMultiple::convertValuesToItems in YAML Form 8
Convert an array containing of values (elements or _item_ and weight) to an array of items.
Parameters
array $element: The element.
array $values: An array containing of item and weight.
Return value
array An array of items.
1 call to YamlFormMultiple::convertValuesToItems()
- YamlFormMultiple::validateYamlFormMultiple in src/
Element/ YamlFormMultiple.php - Validates form list element.
File
- src/
Element/ YamlFormMultiple.php, line 460
Class
- YamlFormMultiple
- Provides a form element to assist in creation of multiple elements.
Namespace
Drupal\yamlform\ElementCode
public static function convertValuesToItems(array &$element, array $values = []) {
// Sort the item values.
uasort($values, [
'Drupal\\Component\\Utility\\SortArray',
'sortByWeightElement',
]);
// Now build the associative array of items.
$items = [];
foreach ($values as $value) {
if (isset($value['_item_'])) {
if (!self::isEmpty($value['_item_'])) {
$items[] = $value['_item_'];
}
}
else {
unset($value['weight'], $value['_operations_']);
if (!self::isEmpty($value)) {
$items[] = $value;
}
}
}
return $items;
}