W3cubDocs

/Drupal 8

public static function OptGroup::flattenOptions

public static OptGroup::flattenOptions(array $array)

Allows PHP array processing of multiple select options with the same value.

Used for form select elements which need to validate HTML option groups and multiple options which may return the same value. Associative PHP arrays cannot handle these structures, since they share a common key.

Parameters

array $array: The form options array to process.

Return value

array An array with all hierarchical elements flattened to a single array.

File

core/lib/Drupal/Core/Form/OptGroup.php, line 23

Class

OptGroup
Provides helpers for HTML option groups.

Namespace

Drupal\Core\Form

Code

public static function flattenOptions(array $array) {
  $options = array();
  static::doFlattenOptions($array, $options);
  return $options;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Form!OptGroup.php/function/OptGroup::flattenOptions/8.1.x