You are here

protected function Extras::extrasElement in GridStack 8.2

Provides extras form elements.

1 call to Extras::extrasElement()
Form::styleForm in src/Plugin/gridstack/stylizer/Form.php

File

src/Plugin/gridstack/stylizer/Extras.php, line 61

Class

Extras
Provides the extras styles.

Namespace

Drupal\gridstack\Plugin\gridstack\stylizer

Code

protected function extrasElement($optionset, FormStateInterface $form_state, array $settings, array $extras = []) {
  $context = $settings['_scope'];
  $options = [];
  foreach (static::options() as $key => $title) {
    if ($this
      ->isWideRegionOption($key) && empty($settings['_fullwidth'])) {
      continue;
    }
    if (in_array($key, [
      'shrink',
    ]) && !$optionset
      ->isFramework()) {
      continue;
    }
    $options[$key] = $this
      ->t('@title', [
      '@title' => $title,
    ]);
  }
  if ($context != GridStackDefault::ROOT) {
    unset($options['parallax'], $options['parallax-fs']);
  }
  $css_classes = [
    'form-wrapper--extras',
    'is-collapsible',
    'is-collapsed',
    'is-gs-fieldset',
  ];
  $values = $settings['extras'];
  return [
    '#type' => 'checkboxes',
    '#options' => $options,
    '#title' => $this
      ->t('Applicable for image above, not blocks'),
    '#default_value' => empty($values) ? [] : array_values($values),
    '#attributes' => [
      'class' => $css_classes,
    ],
    '#after_build' => [
      [
        $this,
        'afterBuildExtras',
      ],
    ],
    '#region' => $context,
    '#settings' => $settings,
  ];
}