You are here

public function AddVariantSelectionForm::add in Page Manager 8

Same name and namespace in other branches
  1. 8.4 page_manager_ui/src/Form/AddVariantSelectionForm.php \Drupal\page_manager_ui\Form\AddVariantSelectionForm::add()

Overrides ManageConditions::add

File

page_manager_ui/src/Form/AddVariantSelectionForm.php, line 81
Contains \Drupal\page_manager_ui\Form\AddVariantSelectionForm.

Class

AddVariantSelectionForm

Namespace

Drupal\page_manager_ui\Form

Code

public function add(array &$form, FormStateInterface $form_state) {
  $cached_values = $form_state
    ->getTemporaryValue('wizard');
  $page_variant = $cached_values['page_variant'];
  $condition = $form_state
    ->getValue('conditions');
  $content = \Drupal::formBuilder()
    ->getForm($this
    ->getConditionClass(), $condition, $this
    ->getTempstoreId(), $this->machine_name, $page_variant
    ->id());
  $content['#attached']['library'][] = 'core/drupal.dialog.ajax';
  list(, $route_parameters) = $this
    ->getOperationsRouteInfo($cached_values, $this->machine_name, $form_state
    ->getValue('conditions'));
  $content['submit']['#attached']['drupalSettings']['ajax'][$content['submit']['#id']]['url'] = $this
    ->url($this
    ->getAddRoute($cached_values), $route_parameters, [
    'query' => [
      FormBuilderInterface::AJAX_FORM_REQUEST => TRUE,
    ],
  ]);
  $response = new AjaxResponse();
  $response
    ->addCommand(new OpenModalDialogCommand($this
    ->t('Configure Required Context'), $content, array(
    'width' => '700',
  )));
  return $response;
}