You are here

public function ViewsMegarowEditController::jsonCallback in Views Megarow 8

File

src/Controller/ViewsMegarowEditController.php, line 28

Class

ViewsMegarowEditController

Namespace

Drupal\views_megarow\Controller

Code

public function jsonCallback() {

  //$form = $this->form();
  $renderer = \Drupal::service('renderer');
  $output = $renderer
    ->renderRoot($form);
  $title = $form_state
    ->get('title') ?: '';
  $response = new AjaxResponse();
  $form['#attached']['library'][] = 'core/drupal.dialog.ajax';
  $response
    ->setAttachments($form['#attached']);
  $display = '';
  $status_messages = array(
    '#type' => 'status_messages',
  );
  if ($messages = $renderer
    ->renderRoot($status_messages)) {
    $display = '<div class="views-messages">' . $messages . '</div>';
  }
  $display .= $output;
  $options = array(
    /*'dialogClass' => 'views-ui-dialog js-views-ui-dialog',*/
    'width' => '75%',
  );
  $response
    ->addCommand(new OpenModalDialogCommand($title, $display, $options));
  return $response;
}