You are here

public static function YamlFormElementHelper::getFlattened in YAML Form 8

Flatten a nested array of elements.

Parameters

array $elements: An array of elements.

Return value

array A flattened array of elements.

2 calls to YamlFormElementHelper::getFlattened()
YamlFormTranslationManager::getBaseElements in src/YamlFormTranslationManager.php
Get base form elements from the site's default language.
yamlform_update_8067 in includes/yamlform.update.inc
Issue #2825410: Allow forms labels to be translatable.

File

src/Utility/YamlFormElementHelper.php, line 271

Class

YamlFormElementHelper
Helper class form element methods.

Namespace

Drupal\yamlform\Utility

Code

public static function getFlattened(array $elements) {
  $flattened_elements = [];
  foreach ($elements as $key => &$element) {
    if (Element::property($key) || !is_array($element)) {
      continue;
    }
    $flattened_elements[$key] = self::getProperties($element);
    $flattened_elements += self::getFlattened($element);
  }
  return $flattened_elements;
}