public function PanelizerWizardContextForm::addContext in Panelizer 8.3
Same name and namespace in other branches
- 8.5 src/Form/PanelizerWizardContextForm.php \Drupal\panelizer\Form\PanelizerWizardContextForm::addContext()
- 8.4 src/Form/PanelizerWizardContextForm.php \Drupal\panelizer\Form\PanelizerWizardContextForm::addContext()
Overrides ManageContext::addContext
File
- src/
Form/ PanelizerWizardContextForm.php, line 138
Class
- PanelizerWizardContextForm
- Simple wizard step form.
Namespace
Drupal\panelizer\FormCode
public function addContext(array &$form, FormStateInterface $form_state) {
$cached_values = $form_state
->getTemporaryValue('wizard');
$context = $form_state
->getValue('context');
$content = $this->formBuilder
->getForm($this
->getContextClass($cached_values), $context, $this
->getTempstoreId(), $this->machine_name);
$content['#attached']['library'][] = 'core/drupal.dialog.ajax';
list(, $route_parameters) = $this
->getContextOperationsRouteInfo($cached_values, $this->machine_name, $context);
$content['submit']['#attached']['drupalSettings']['ajax'][$content['submit']['#id']]['url'] = $this
->url($this
->getContextAddRoute($cached_values), $route_parameters, [
'query' => [
FormBuilderInterface::AJAX_FORM_REQUEST => TRUE,
],
]);
$response = new AjaxResponse();
$response
->addCommand(new OpenModalDialogCommand($this
->t('Add new context'), $content, [
'width' => '700',
]));
return $response;
}