function OptGroup::flattenOptions

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Form/OptGroup.php \Drupal\Core\Form\OptGroup::flattenOptions()
  2. 10 core/lib/Drupal/Core/Form/OptGroup.php \Drupal\Core\Form\OptGroup::flattenOptions()
  3. 11.x core/lib/Drupal/Core/Form/OptGroup.php \Drupal\Core\Form\OptGroup::flattenOptions()

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.

10 calls to OptGroup::flattenOptions()
EntityReferenceItem::getSettableValues in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
Returns an array of settable values.
FormValidator::performRequiredValidation in core/lib/Drupal/Core/Form/FormValidator.php
Performs validation of elements that are not subject to limited validation.
InOperator::adminSummary in core/modules/views/src/Plugin/views/filter/InOperator.php
Display the filter on the administrative summary.
InOperator::validate in core/modules/views/src/Plugin/views/filter/InOperator.php
Validate that the plugin is correct and can be saved.
ListItemBase::getPossibleValues in core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
Returns an array of possible values.

... See full list

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 = [];
    static::doFlattenOptions($array, $options);
    return $options;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.