You are here

protected function OptionsBase::getElementSelectorInputsOptions in YAML Form 8

Get an element's (sub)inputs selectors as options.

Parameters

array $element: An element.

Return value

array An array of element (sub)input selectors.

Overrides YamlFormElementBase::getElementSelectorInputsOptions

2 methods override OptionsBase::getElementSelectorInputsOptions()
Checkboxes::getElementSelectorInputsOptions in src/Plugin/YamlFormElement/Checkboxes.php
Get an element's (sub)inputs selectors as options.
YamlFormToggles::getElementSelectorInputsOptions in src/Plugin/YamlFormElement/YamlFormToggles.php
Get an element's (sub)inputs selectors as options.

File

src/Plugin/YamlFormElement/OptionsBase.php, line 427

Class

OptionsBase
Provides a base 'options' element.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

protected function getElementSelectorInputsOptions(array $element) {
  $plugin_id = $this
    ->getPluginId();
  if (preg_match('/yamlform_(select|radios|checkboxes|buttons)_other$/', $plugin_id, $match)) {
    $title = $this
      ->getAdminLabel($element);
    list($element_type) = explode(' ', $this
      ->getPluginLabel());
    $inputs = [];
    $inputs[$match[1]] = $title . ' [' . $element_type . ']';
    $inputs['other'] = $title . ' [' . $this
      ->t('Text field') . ']';
    return $inputs;
  }
  else {
    return [];
  }
}