You are here

public function GridStackAdmin::buildSettingsForm in GridStack 8

Same name and namespace in other branches
  1. 8.2 src/Form/GridStackAdmin.php \Drupal\gridstack\Form\GridStackAdmin::buildSettingsForm()

Returns all settings form elements.

File

src/Form/GridStackAdmin.php, line 70

Class

GridStackAdmin
Provides resusable admin functions or form elements.

Namespace

Drupal\gridstack\Form

Code

public function buildSettingsForm(array &$form, $definition = []) {
  $definition['namespace'] = 'gridstack';
  $definition['skins'] = $this
    ->getSkinOptions();
  $definition['style'] = FALSE;
  $definition['grid_form'] = FALSE;
  $optionsets = [];
  $entities = $this->manager
    ->entityLoadMultiple('gridstack');
  foreach ($entities as $key => $entity) {

    // Exludes Boostrap/ Foundation grids which only work for DS, Panels.
    if ($entity
      ->getOption('use_framework')) {
      continue;
    }
    $optionsets[$key] = Html::escape($entity
      ->label());
  }
  $definition['optionsets'] = $optionsets;
  foreach ([
    'background',
    'caches',
    'fieldable_form',
    'id',
    'vanilla',
  ] as $key) {
    $definition[$key] = isset($definition[$key]) ? $definition[$key] : TRUE;
  }
  $definition['layouts'] = isset($definition['layouts']) ? array_merge($this
    ->getLayoutOptions(), $definition['layouts']) : $this
    ->getLayoutOptions();
  $this
    ->openingForm($form, $definition);
  $this
    ->mainForm($form, $definition);
  $this
    ->closingForm($form, $definition);
}