You are here

protected function WebformSubmissionForm::getCurrentPage in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformSubmissionForm.php \Drupal\webform\WebformSubmissionForm::getCurrentPage()

Get the current page's key.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

string The current page's key.

8 calls to WebformSubmissionForm::getCurrentPage()
WebformSubmissionForm::actions in src/WebformSubmissionForm.php
Returns an array of supported actions for the current entity form.
WebformSubmissionForm::attachBehaviors in src/WebformSubmissionForm.php
Attach behaviors with libraries to the form.
WebformSubmissionForm::copyFormValuesToEntity in src/WebformSubmissionForm.php
Copies top-level form values to entity properties
WebformSubmissionForm::displayCurrentPage in src/WebformSubmissionForm.php
Set webform wizard current page.
WebformSubmissionForm::form in src/WebformSubmissionForm.php
Gets the actual form array to be built.

... See full list

File

src/WebformSubmissionForm.php, line 2229

Class

WebformSubmissionForm
Provides a webform to collect and edit submissions.

Namespace

Drupal\webform

Code

protected function getCurrentPage(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->get('current_page') === NULL) {
    $pages = $this
      ->getWebform()
      ->getPages($this->operation);
    if (empty($pages)) {
      $form_state
        ->set('current_page', '');
    }
    else {
      $current_page = $this->entity
        ->getCurrentPage();
      if ($current_page && isset($pages[$current_page]) && !$this->entity
        ->isCompleted()) {
        $form_state
          ->set('current_page', $current_page);
      }
      else {
        $form_state
          ->set('current_page', WebformArrayHelper::getFirstKey($pages));
      }
    }
  }
  return $form_state
    ->get('current_page');
}