You are here

public function GridStackLayoutBase::submitConfigurationForm in GridStack 8.2

Form submission handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides LayoutDefault::submitConfigurationForm

File

src/Plugin/Layout/GridStackLayoutBase.php, line 100

Class

GridStackLayoutBase
Provides a GridStack base class for Layout plugins.

Namespace

Drupal\gridstack\Plugin\Layout

Code

public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
  parent::submitConfigurationForm($form, $form_state);
  if ($settings = $form_state
    ->getValue('settings')) {
    $this->styleForm
      ->cleanupStyles($settings['styles']);
    if (isset($settings['global'])) {
      foreach ($settings['global'] as $key => $value) {
        $settings[$key] = $value;
      }
      unset($settings['global']);
    }
    unset($settings['current_selection'], $settings['preset_classes'], $settings['preset_row_classes']);
    foreach ($settings as $key => &$value) {
      $this
        ->massageValues($value, $key);
      $this->configuration[$key] = $value;
    }
  }
  unset($this->configuration['global'], $this->configuration['settings']);
  $regions = [];
  if ($values = $form_state
    ->getValue('regions')) {
    foreach ($values as $name => &$region) {
      $this->styleForm
        ->cleanupStyles($region['styles']);
      foreach ($region as $key => &$value) {
        $this
          ->massageValues($value, $key);
        if (in_array($key, [
          'preset_classes',
          'preset_row_classes',
        ])) {
          continue;
        }
        $regions[$name][$key] = $value;
      }
    }
  }
  $this->configuration['regions'] = $regions;
}