You are here

public function OptionsBase::preview in Webform 6.x

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

Generate a renderable preview of the element.

Return value

array A renderable preview of the element.

Overrides WebformElementBase::preview

1 call to OptionsBase::preview()
WebformImageSelect::preview in modules/webform_image_select/src/Plugin/WebformElement/WebformImageSelect.php
Generate a renderable preview of the element.
2 methods override OptionsBase::preview()
WebformImageSelect::preview in modules/webform_image_select/src/Plugin/WebformElement/WebformImageSelect.php
Generate a renderable preview of the element.
WebformOptionsCustom::preview in modules/webform_options_custom/src/Plugin/WebformElement/WebformOptionsCustom.php
Generate a renderable preview of the element.

File

src/Plugin/WebformElement/OptionsBase.php, line 534

Class

OptionsBase
Provides a base 'options' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function preview() {
  $element = parent::preview();
  if ($this
    ->hasProperty('options')) {
    $element['#options'] = [
      'one' => 'One',
      'two' => 'Two',
      'three' => 'Three',
    ];
  }
  if ($this
    ->hasProperty('options_display')) {
    $element['#options_display'] = 'side_by_side';
  }
  return $element;
}