You are here

protected function SelectOtherWidget::prepareOptions in GatherContent 8.5

Same name and namespace in other branches
  1. 8.4 gathercontent_ui/src/Plugin/Field/FieldWidget/SelectOtherWidget.php \Drupal\gathercontent_ui\Plugin\Field\FieldWidget\SelectOtherWidget::prepareOptions()

Get list of options.

Return value

array Array of options with appended Other option.

1 call to SelectOtherWidget::prepareOptions()
SelectOtherWidget::formElement in gathercontent_ui/src/Plugin/Field/FieldWidget/SelectOtherWidget.php
Returns the form for a single field widget.

File

gathercontent_ui/src/Plugin/Field/FieldWidget/SelectOtherWidget.php, line 83

Class

SelectOtherWidget
Plugin implementation of the 'select_other_widget' widget.

Namespace

Drupal\gathercontent_ui\Plugin\Field\FieldWidget

Code

protected function prepareOptions() {
  $list = explode("\n", $this
    ->getSetting('available_options'));
  $options = [];
  foreach ($list as $item) {
    list($key, $value) = explode('|', $item);
    $value = html_entity_decode($value);
    $options[$key] = $value;
  }
  return $options + [
    'other' => $this
      ->t('Other'),
  ];
}