You are here

public function Form::validateConfigurationForm in GridStack 8.2

Overrides GridStackStylizerPluginBase::validateConfigurationForm

File

src/Plugin/gridstack/stylizer/Form.php, line 91

Class

Form
Provides the form elements.

Namespace

Drupal\gridstack\Plugin\gridstack\stylizer

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  parent::validateConfigurationForm($form, $form_state);
  $settings = $form_state
    ->getValue('settings');
  $form_state
    ->setValue([
    'settings',
    'gridnative',
  ], (bool) $settings['gridnative']);
  $form_state
    ->setValue([
    'settings',
    '_fullwidth',
  ], (bool) $settings['_fullwidth']);
  $key = [
    'settings',
    'wrapper_classes',
  ];
  $this
    ->massageClasses($key, $settings, $form_state);
  $key = [
    'settings',
    'row_classes',
  ];
  $this
    ->massageRowClasses($key, $settings, $form_state);
  $key = [
    'settings',
    'styles',
    'metadata',
  ];
  $this
    ->massageMetadata($key, $settings, $form_state);
  foreach ([
    'animations',
    'colors',
    'extras',
  ] as $key) {
    $setting_name = [
      'settings',
      'styles',
      $key,
    ];
    $this
      ->massageArrayValues($key, $setting_name, $form_state);
  }
  $regions = $form_state
    ->getValue('regions');
  foreach ($regions as $name => $region) {
    $form_state
      ->setValue([
      'regions',
      $name,
      '_fullwidth',
    ], (bool) $region['_fullwidth']);
    $key = [
      'regions',
      $name,
      'wrapper_classes',
    ];
    $this
      ->massageClasses($key, $region, $form_state);
    $key = [
      'regions',
      $name,
      'row_classes',
    ];
    $this
      ->massageRowClasses($key, $region, $form_state);
    $key = [
      'regions',
      $name,
      'styles',
      'metadata',
    ];
    $this
      ->massageMetadata($key, $region, $form_state);
    foreach ([
      'animations',
      'colors',
      'extras',
    ] as $key) {
      $setting_name = [
        'regions',
        $name,
        'styles',
        $key,
      ];
      $this
        ->massageArrayValues($key, $setting_name, $form_state);
    }
  }
}