function webform_cards_preprocess_webform_confirmation in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_cards/webform_cards.module \webform_cards_preprocess_webform_confirmation()
Implements hook_preprocess_webform_confirmation() for webform cards.
File
- modules/
webform_cards/ webform_cards.module, line 626 - Provides a 'Card' container element for clientside multistep form pagination.
Code
function webform_cards_preprocess_webform_confirmation(array &$variables) {
/** @var \Drupal\webform\WebformInterface $webform */
$webform = $variables['webform'];
/** @var \Drupal\webform\WebformSubmissionInterface $webform_submission */
$webform_submission = $variables['webform_submission'];
/** @var \Drupal\webform_cards\WebformCardsManagerInterface $webform_cards_manager */
$webform_cards_manager = \Drupal::service('webform_cards.manager');
// Check if the webform has cards.
$has_cards = $webform_cards_manager
->hasCards($webform);
if (!$has_cards) {
return;
}
// Set progress.
$pages = $webform_cards_manager
->buildPages($webform);
$settings = $webform
->getSettings();
if ($pages && $settings['wizard_confirmation'] && ($settings['wizard_progress_bar'] || $settings['wizard_progress_pages'] || $settings['wizard_progress_percentage'])) {
$variables['progress'] = [
'#theme' => 'webform_progress',
'#webform' => $webform,
'#webform_submission' => $webform_submission,
'#current_page' => WebformInterface::PAGE_CONFIRMATION,
'#pages' => $webform_cards_manager
->applyConditions($pages, $webform_submission),
];
}
}