You are here

protected function GridStackForm::optionsForm in GridStack 8.2

Sets up the options form.

1 call to GridStackForm::optionsForm()
GridStackForm::form in modules/gridstack_ui/src/Form/GridStackForm.php
Gets the actual form array to be built.

File

modules/gridstack_ui/src/Form/GridStackForm.php, line 63

Class

GridStackForm
Extends base form for gridstack instance configuration form.

Namespace

Drupal\gridstack_ui\Form

Code

protected function optionsForm(array &$form, FormStateInterface $form_state) {
  $classes = [
    'details--settings',
    'has-tooltip',
  ];
  $form['options'] = [
    '#type' => 'container',
    '#tree' => TRUE,
    '#title' => $this
      ->t('Options'),
    '#title_display' => 'invisible',
    '#attributes' => [
      'class' => $classes,
      'id' => 'edit-options',
    ],
    '#access' => $this
      ->gridStack()
      ->id() == 'default' ? FALSE : TRUE,
  ];
  $form['options']['icon'] = [
    '#type' => 'hidden',
    '#default_value' => isset($this->options['icon']) ? $this->options['icon'] : '',
    '#attributes' => [
      'id' => 'gridstack-icon',
      'data-url' => $this->entity
        ->getIconUrl(TRUE),
    ],
  ];
  $form['options']['use_framework'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Use static <span>@framework</span>', [
      '@framework' => $this->framework,
    ]),
    '#default_value' => $this
      ->gridStack()
      ->getOption('use_framework'),
    '#description' => $this
      ->getDescription('use_framework'),
    '#wrapper_attributes' => [
      'class' => [
        'form-item--options-use-framework',
        'form-item--tooltip-bottom',
      ],
    ],
    '#disabled' => $this->useNested,
  ];
  if ($this->adminCss) {
    $form['options']['use_framework']['#field_suffix'] = '&nbsp;';
    $form['options']['use_framework']['#title_display'] = 'before';
  }
}