You are here

public static function YamlFormExcludedBase::getYamlFormExcludedOptions in YAML Form 8

Get options for excluded tableselect element.

Parameters

array $element: An associative array containing the properties and children of the generic element element.

Return value

array An array of options containing title, name, and type of items for a tableselect element.

2 calls to YamlFormExcludedBase::getYamlFormExcludedOptions()
YamlFormExcludedBase::processYamlFormExcluded in src/Element/YamlFormExcludedBase.php
Processes a form elements form element.
YamlFormExcludedColumns::getYamlFormExcludedOptions in src/Element/YamlFormExcludedColumns.php
Get options for excluded tableselect element.
1 method overrides YamlFormExcludedBase::getYamlFormExcludedOptions()
YamlFormExcludedColumns::getYamlFormExcludedOptions in src/Element/YamlFormExcludedColumns.php
Get options for excluded tableselect element.

File

src/Element/YamlFormExcludedBase.php, line 90

Class

YamlFormExcludedBase
Provides a base form element for form excluded elements and columns.

Namespace

Drupal\yamlform\Element

Code

public static function getYamlFormExcludedOptions(array $element) {

  /** @var \Drupal\yamlform\YamlFormInterface $yamlform */
  $yamlform = $element['#yamlform'];

  /** @var \Drupal\yamlform\YamlFormElementManagerInterface $element_manager */
  $element_manager = \Drupal::service('plugin.manager.yamlform.element');
  $options = [];
  $elements = $yamlform
    ->getElementsInitializedAndFlattened();
  foreach ($elements as $key => $element) {
    $element_handler = $element_manager
      ->getElementInstance($element);
    if (!$element_handler
      ->isInput($element)) {
      continue;
    }
    $options[$key] = [
      [
        'title' => $element['#admin_title'] ?: $element['#title'] ?: $key,
      ],
      [
        'name' => $key,
      ],
      [
        'type' => isset($element['#type']) ? $element['#type'] : '',
      ],
    ];
  }
  return $options;
}