You are here

public function WebformEntityReferenceTrait::preview in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformEntityReferenceTrait.php \Drupal\webform\Plugin\WebformElement\WebformEntityReferenceTrait::preview()
1 method overrides WebformEntityReferenceTrait::preview()
WebformTermReferenceTrait::preview in src/Plugin/WebformElement/WebformTermReferenceTrait.php

File

src/Plugin/WebformElement/WebformEntityReferenceTrait.php, line 224

Class

WebformEntityReferenceTrait
Provides an 'entity_reference' trait.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function preview() {
  $element = parent::preview();
  $element += [
    '#target_type' => 'user',
    '#selection_handler' => 'default:user',
    '#selection_settings' => [
      'include_anonymous' => TRUE,
    ],
  ];
  if ($this instanceof OptionsBase) {
    $element['#options'] = [
      '1' => 'Administrator',
      '0' => 'Anonymous',
    ];
  }
  return $element;
}