/**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state, PageInterface $page = NULL, $page_variant_id = NULL, $layout_region_id = NULL)
 {
     $this->page = $page;
     $this->pageVariant = $page->getVariant($page_variant_id);
     $this->pageVariant->init($this->page->getExecutable());
     $this->layoutRegion = $this->pageVariant->getLayoutRegion($layout_region_id);
     $form = parent::buildForm($form, $form_state);
     if ($this->getRequest()->isXmlHttpRequest()) {
         $form['actions']['submit']['#ajax'] = array('callback' => array($this, 'submitForm'));
     }
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state, PageInterface $page = NULL, $page_variant_id = NULL, $layout_region_id = NULL, $plugin_id = NULL)
 {
     $this->page = $page;
     $this->pageVariant = $page->getVariant($page_variant_id);
     $this->pageVariant->init($page->getExecutable());
     // Check for adding a (sub-)region to an existent region.
     if ($plugin_id) {
         $this->layoutRegion = $this->prepareLayoutRegion($plugin_id, $layout_region_id);
         $this->layoutRegion->parentLayoutRegion = $this->pageVariant->getLayoutRegion($layout_region_id);
     } else {
         $this->layoutRegion = $this->prepareLayoutRegion($layout_region_id);
     }
     // Allow the page variant to add to the form.
     $form['plugin'] = $this->layoutRegion->buildConfigurationForm(array(), $form_state);
     $form['plugin']['#tree'] = TRUE;
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->submitText(), '#button_type' => 'primary');
     if ($this->getRequest()->isXmlHttpRequest()) {
         $form['actions']['submit']['#ajax'] = array('callback' => array($this, 'submitForm'));
     }
     return $form;
 }