You are here

public function ParameterEditForm::submitForm in Page Manager 8

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

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

page_manager_ui/src/Form/ParameterEditForm.php, line 188
Contains \Drupal\page_manager_ui\Form\ParameterEditForm.

Class

ParameterEditForm
Provides a form for editing a parameter.

Namespace

Drupal\page_manager_ui\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $cache_values = $this
    ->getTempstore();

  /** @var \Drupal\page_manager\PageInterface $page */
  $page = $cache_values['page'];
  $name = $form_state
    ->getValue('machine_name');
  $type = $form_state
    ->getValue('type');
  if ($type === static::NO_CONTEXT_KEY) {
    $page
      ->removeParameter($name);
    $label = NULL;
  }
  else {
    $label = $form_state
      ->getValue('label');
    $page
      ->setParameter($name, $type, $label);
  }
  $this
    ->setTempstore($cache_values);
  drupal_set_message($this
    ->t('The %label parameter has been updated.', [
    '%label' => $label ?: $name,
  ]));
  list($route_name, $route_parameters) = $this
    ->getParentRouteInfo($cache_values);
  $form_state
    ->setRedirect($route_name, $route_parameters);
}