You are here

protected function WebformOptionsCustom::setOptions in Webform 6.x

Same name in this branch
  1. 6.x modules/webform_options_custom/src/Element/WebformOptionsCustom.php \Drupal\webform_options_custom\Element\WebformOptionsCustom::setOptions()
  2. 6.x modules/webform_options_custom/src/Entity/WebformOptionsCustom.php \Drupal\webform_options_custom\Entity\WebformOptionsCustom::setOptions()
  3. 6.x modules/webform_options_custom/src/Plugin/WebformElement/WebformOptionsCustom.php \Drupal\webform_options_custom\Plugin\WebformElement\WebformOptionsCustom::setOptions()
Same name and namespace in other branches
  1. 8.5 modules/webform_options_custom/src/Plugin/WebformElement/WebformOptionsCustom.php \Drupal\webform_options_custom\Plugin\WebformElement\WebformOptionsCustom::setOptions()

Get element custom options.

Parameters

array $element: An element.

array $settings: An array of settings used to limit and randomize options.

6 calls to WebformOptionsCustom::setOptions()
WebformOptionsCustom::build in modules/webform_options_custom/src/Plugin/WebformElement/WebformOptionsCustom.php
Build an element as text or HTML.
WebformOptionsCustom::form in modules/webform_options_custom/src/Plugin/WebformElement/WebformOptionsCustom.php
Gets the actual configuration webform array to be built.
WebformOptionsCustom::getElementSelectorInputsOptions in modules/webform_options_custom/src/Plugin/WebformElement/WebformOptionsCustom.php
Get an element's (sub)inputs selectors as options.
WebformOptionsCustom::getElementSelectorSourceValues in modules/webform_options_custom/src/Plugin/WebformElement/WebformOptionsCustom.php
Get an element's selectors source values.
WebformOptionsCustom::getTestValues in modules/webform_options_custom/src/Plugin/WebformElement/WebformOptionsCustom.php
Get test values for an element.

... See full list

File

modules/webform_options_custom/src/Plugin/WebformElement/WebformOptionsCustom.php, line 241

Class

WebformOptionsCustom
Provides a custom options element.

Namespace

Drupal\webform_options_custom\Plugin\WebformElement

Code

protected function setOptions(array &$element, array $settings = []) {

  // Set element options.
  if (!empty($element['#options'])) {
    $element['#options'] = WebformOptions::getElementOptions($element);
  }

  // Set element custom template options.
  list($type, $options_custom) = explode(':', $this
    ->getPluginId());
  $element['#type'] = $type;
  $element['#options_custom'] = $options_custom;

  /** @var \Drupal\webform_options_custom\Element\WebformOptionsCustomInterface $class */
  $class = $this
    ->getFormElementClassDefinition();
  $class::setTemplateOptions($element);
}