You are here

public function RequiredContext::add in Chaos Tool Suite (ctools) 8.3

Custom ajax form submission handler.

Parameters

array $form:

\Drupal\Core\Form\FormStateInterface $form_state:

Return value

\Drupal\Core\Ajax\AjaxResponse

File

src/Form/RequiredContext.php, line 113

Class

RequiredContext

Namespace

Drupal\ctools\Form

Code

public function add(array &$form, FormStateInterface $form_state) {
  $context = $form_state
    ->getValue('contexts');
  $content = $this->formBuilder
    ->getForm($this
    ->getContextClass(), $context, $this
    ->getTempstoreId(), $this->machine_name);
  $content['#attached']['library'][] = 'core/drupal.dialog.ajax';
  $response = new AjaxResponse();
  $response
    ->addCommand(new OpenModalDialogCommand($this
    ->t('Configure Required Context'), $content, [
    'width' => '700',
  ]));
  return $response;
}