You are here

public function PageVariantAddWizard::buildForm in Page Manager 8.4

Same name and namespace in other branches
  1. 8 page_manager_ui/src/Wizard/PageVariantAddWizard.php \Drupal\page_manager_ui\Wizard\PageVariantAddWizard::buildForm()

Form constructor.

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

array The form structure.

Overrides FormWizardBase::buildForm

File

page_manager_ui/src/Wizard/PageVariantAddWizard.php, line 129

Class

PageVariantAddWizard

Namespace

Drupal\page_manager_ui\Wizard

Code

public function buildForm(array $form, FormStateInterface $form_state, $page = NULL) {

  // TODO: Change the autogenerated stub.
  $form = parent::buildForm($form, $form_state);

  // Get the page tempstore so we can modify the unsaved page.
  if (!isset($cached_values['page']) || !$cached_values['page']
    ->id()) {
    $cached_values = $form_state
      ->getTemporaryValue('wizard');
    $page_tempstore = $this->tempstore
      ->get('page_manager.page')
      ->get($page);
    $cached_values['page'] = $page_tempstore['page'];
    $form_state
      ->setTemporaryValue('wizard', $cached_values);
  }

  // Hide form elements that are not useful during the add wizard.
  if ($this->step == 'configure') {
    $form['page_variant_label']['#type'] = 'value';
    unset($form['delete']);
  }
  return $form;
}