You are here

public function GridStackLayoutTrait::submitConfigurationForm in GridStack 8

File

src/Layout/GridStackLayoutTrait.php, line 128

Class

GridStackLayoutTrait
A Trait common for optional layout integration.

Namespace

Drupal\gridstack\Layout

Code

public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
  $regions = $form_state
    ->getValue('regions');
  $settings = $form_state
    ->getValue('settings');
  if (!empty($settings)) {
    foreach ($settings as $key => $value) {
      $this->configuration[$key] = trim(strip_tags($value));
    }
    unset($this->configuration['settings']);
  }
  if (!empty($regions)) {
    $stored_regions = [];
    foreach ($regions as $name => $info) {
      $region = $form_state
        ->getValue([
        'regions',
        $name,
      ]);
      foreach ($region as $key => $value) {
        $stored_regions[$name][$key] = trim(strip_tags($value));
        if (empty($value)) {
          unset($stored_regions[$name][$key]);
        }
      }
    }
    $this->configuration['regions'] = $stored_regions;
  }
}