You are here

protected function YamlFormSubmissionForm::getCurrentPage in YAML Form 8

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.

6 calls to YamlFormSubmissionForm::getCurrentPage()
YamlFormSubmissionForm::actions in src/YamlFormSubmissionForm.php
Returns an array of supported actions for the current entity form.
YamlFormSubmissionForm::displayCurrentPage in src/YamlFormSubmissionForm.php
Set form wizard current page.
YamlFormSubmissionForm::form in src/YamlFormSubmissionForm.php
Gets the actual form array to be built.
YamlFormSubmissionForm::getNextPage in src/YamlFormSubmissionForm.php
Get next page's key.
YamlFormSubmissionForm::getPreviousPage in src/YamlFormSubmissionForm.php
Get previous page's key.

... See full list

File

src/YamlFormSubmissionForm.php, line 921

Class

YamlFormSubmissionForm
Provides a form to collect and edit submissions.

Namespace

Drupal\yamlform

Code

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