You are here

public function PanelsContentForm::submitForm in Panels 8.3

Same name and namespace in other branches
  1. 8.4 src/Form/PanelsContentForm.php \Drupal\panels\Form\PanelsContentForm::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

src/Form/PanelsContentForm.php, line 231

Class

PanelsContentForm
Provides a form for editing a panel variant display's content.

Namespace

Drupal\panels\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $cached_values = $form_state
    ->getTemporaryValue('wizard');

  /** @var \Drupal\page_manager\Plugin\DisplayVariant\PageBlockDisplayVariant $variant_plugin */
  $variant_plugin = $cached_values['plugin'];

  // If the blocks were rearranged, update their values.
  if (!$form_state
    ->isValueEmpty('blocks')) {
    foreach ($form_state
      ->getValue('blocks') as $block_id => $block_values) {
      $variant_plugin
        ->updateBlock($block_id, $block_values);
    }
  }

  // Page Variant title handling.
  if ($form_state
    ->hasValue('page_title')) {
    $configuration = $variant_plugin
      ->getConfiguration();
    $configuration['page_title'] = $form_state
      ->getValue('page_title');
    $variant_plugin
      ->setConfiguration($configuration);
  }
}