You are here

protected function WebformWizardPage::formatHtmlItem in Webform 6.x

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

Format an element's value as HTML.

Parameters

array $element: An element.

\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.

array $options: An array of options.

Return value

array|string The element's value formatted as HTML or a render array.

Overrides ContainerBase::formatHtmlItem

File

src/Plugin/WebformElement/WebformWizardPage.php, line 85

Class

WebformWizardPage
Provides a 'webform_wizard_page' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

protected function formatHtmlItem(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
  $build = parent::formatHtmlItem($element, $webform_submission, $options);

  // Add edit page link container to preview.
  // @see Drupal.behaviors.webformWizardPagesLink
  if ($build && isset($options['view_mode']) && $options['view_mode'] === 'preview' && $webform_submission
    ->getWebform()
    ->getSetting('wizard_preview_link')) {
    $build['#children']['wizard_page_link'] = [
      '#type' => 'container',
      '#attributes' => [
        'data-webform-page' => $element['#webform_key'],
        'class' => [
          'webform-wizard-page-edit',
        ],
      ],
    ];
  }
  return $build;
}