You are here

public function Form::buildConfigurationForm in GridStack 8.2

File

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

Class

Form
Provides the form elements.

Namespace

Drupal\gridstack\Plugin\gridstack\stylizer

Code

public function buildConfigurationForm($optionset, FormStateInterface $form_state, array $settings, array $extras = []) {
  $context = $settings['_scope'];
  $element = [];

  // Provides global elements.
  if ($context == GridStackDefault::ROOT) {
    $settings['_fullwidth'] = TRUE;
    $element = array_merge($element, $this
      ->globalForm($optionset, $form_state, $settings, $extras));
  }

  // Provides wrapper elements.
  $element = array_merge($element, $this
    ->wrapperForm($optionset, $form_state, $settings, $extras));
  foreach ([
    'target_id',
    '_fullwidth',
  ] as $key) {
    $element[$key]['#type'] = 'hidden';
    $element[$key]['#default_value'] = isset($settings[$key]) ? $settings[$key] : '';
  }
  $element['target_id']['#attributes']['data-gs-media-storage'] = $context;

  // Provides ranges, colors, and extra elements.
  $element = array_merge($element, $this
    ->styleForm($optionset, $form_state, $settings, $extras));
  return $element;
}