You are here

public function WebformOptionsCustom::preview in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_options_custom/src/Plugin/WebformElement/WebformOptionsCustom.php \Drupal\webform_options_custom\Plugin\WebformElement\WebformOptionsCustom::preview()

Generate a renderable preview of the element.

Return value

array A renderable preview of the element.

Overrides OptionsBase::preview

File

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

Class

WebformOptionsCustom
Provides a custom options element.

Namespace

Drupal\webform_options_custom\Plugin\WebformElement

Code

public function preview() {
  list(, $webform_options_custom_id) = explode(':', $this
    ->getPluginId());

  /** @var \Drupal\webform_options_custom\WebformOptionsCustomInterface $webform_options_custom */
  $webform_options_custom = $this->entityTypeManager
    ->getStorage('webform_options_custom')
    ->load($webform_options_custom_id);
  return $webform_options_custom
    ->getPreview() + [
    '#title' => $webform_options_custom
      ->label(),
  ];
}