You are here

protected function AjaxPageControllerBase::getForm in Forena Reports 8

Retrieve a drupal form for inclusion in the app. Will load based on controlllerr's jsMode property as either an ajax command or as an inline form.

Parameters

string $section: The section of the template in which to render the form.

string $class: The class name of the form to render.

File

src/Controller/AjaxPageControllerBase.php, line 467

Class

AjaxPageControllerBase

Namespace

Drupal\forena\Controller

Code

protected function getForm($section, $class) {
  $modal = $this->is_modal_form;
  $this->prior_section = $this->section;
  $this->section = $section;
  $this->is_modal_form = FALSE;

  // We need to skip the second redering of this form in a route because
  // it may lead to an ajax error.  It should already have been rendered
  // in the form processing phase.
  if (empty($_POST['form_id']) || $class::FORM_ID != $this->post_form_id) {
    $content = \Drupal::formBuilder()
      ->getForm($class);
    if ($this->jsMode != 'nojs' && $this->jsMode != 'drupal_modal') {
      $this->commands = array_merge($this->commands, $this
        ->generateAjaxReplace($section, $content));
    }
    else {
      $this->build[$section] = $content;
    }
    $this->is_modal_form = $modal;
    $this->section = $this->prior_section;
  }
}