0

I can't find a way to move the progress bar to below the form. I've looked all through the UI options and also examined the Twig templates that are used to render the progress bar but there does not seem to be a way to move it. Is it being inserted through a process hook? Can't figure this one out.

enter image description here

1 Answer 1

1

You can do it in the hook_webform_submission_form_alter.

You need to unset '#weight' array key in the render element for the progress bar and move it to the appropriate place where you want it rendered.

Example:

function hook_webform_submission_form_alter(array &$form, FormStateInterface $form_state, string $form_id): void {
  if ($form_id === 'your_webform_form_id') {
    if (
      array_key_exists('progress', $form)
      && array_key_exists('#weight', $form['progress'])
      && array_key_exists('#current_page', $form['progress'])
      && $form['progress']['#current_page'] === 'my_page'
    ) {
      unset($form['progress']['#weight']);
      $progress = $form['progress'];

      $index = array_search('element_to_be_placed_after', array_keys($form['elements']['my_page']));
      $changedArray = array_slice($form['elements']['my_page'], 0, $index, TRUE)
        + ['progress' => $progress]
        + array_slice($form['elements']['my_page'], $index, NULL, TRUE);
      $form['elements']['my_page'] = $changedArray;
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.