You are here

public function AjaxFormTrait::bindAjaxForm in Forena Reports 8

Parameters

\Drupal\forena\Controller\AjaxPageControllerBase $controller:

$form:

\Drupal\Core\Form\FormStateInterface $form_state:

File

src/Form/AjaxFormTrait.php, line 124

Class

AjaxFormTrait
Class AjaxFormTrait

Namespace

Drupal\forena\Form

Code

public function bindAjaxForm(AjaxPageControllerBase $controller, &$form, FormStateInterface $form_state) {
  if ($controller->is_modal_form && $controller->jsMode != 'nojs') {
    $form_state
      ->set('e_modal', TRUE);
    $form['#prefix'] = "<div id='e-modal-form'>";
    $form['#suffix'] = "</div>";
  }
  else {
    $form_state
      ->set('e_section', $controller->section);
  }
  $form[$controller::TOKEN_PARAMETER] = [
    '#type' => 'hidden',
    '#value' => $controller
      ->getStateToken(),
  ];

  // Disable caching on this form.
  $form_state
    ->setCached(FALSE);

  // Set the form state handler.
  $controller->form_state = $form_state;

  // Alter the submit handlers.
  $this->controller = $controller;
  $method = "::submitCallback";
  $callback = $method;
  $this
    ->alterForm($form, $callback);
}