Hi

I've created a multipage webform with the Preview page enabled. I can change the text on the button of the final page before the Preview page, but I can't seem to change the Title of the Preview page (nor change the text 'Preview' in the progress bar). Is there a way to edit this text?

Thanks

F

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

frankdesign created an issue. See original summary.

jrockowitz’s picture

Here is the code snippet I came up with...


function CUSTOM_MODULE_webform_submission_form_alter(array &$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  // Alter the preview page's title.
  if ($form_state->get('current_page') == 'preview') {
    $form['#title'] = t('Custom preview title');
  }
}

function CUSTOM_MODULE_preprocess_webform_progress_bar(array &$variables) {
  // Alter preview wizard title.
  /** @var \Drupal\webform\WebformInterface $webform */
  $webform = $variables['webform'];
  $pages = $webform->getPages();
  $variables['progress'] = [];
  foreach ($pages as $name => $page) {
    if ($name == 'preview') {
      $variables['progress'][] = t('Custom preview title');
    }
    else {
      $variables['progress'][] = (isset($page['#title'])) ? $page['#title'] : '';
    }
  }
}
jrockowitz’s picture

Status: Active » Needs review
frankdesign’s picture

Perfect - that works great. Thanks a mil

F

jrockowitz’s picture

Status: Needs review » Needs work

Let's leave this ticket open since, I think form builders should be able to customize the preview pages label and title.

  • jrockowitz committed d8d24dc on 2872464-preview-title
    Issue #2872464: MultiStep Preview Page - change the Page Title and...
jrockowitz’s picture

Status: Needs work » Needs review
FileSize
92.85 KB

  • jrockowitz committed 3177b3f on 8.x-5.x
    Issue #2872464 by jrockowitz: MultiStep Preview Page - change the Page...
jrockowitz’s picture

Status: Needs review » Fixed

The preview wizard label and page title are now customizable.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.