You are here

protected function GridStackFormBase::regionForm in GridStack 8.2

Returns the region form.

1 call to GridStackFormBase::regionForm()
GridStackFormBase::initEngine in modules/gridstack_ui/src/Form/GridStackFormBase.php
Initializes the layout engine.

File

modules/gridstack_ui/src/Form/GridStackFormBase.php, line 433

Class

GridStackFormBase
Extends base form for gridstack instance configuration form.

Namespace

Drupal\gridstack_ui\Form

Code

protected function regionForm(array &$form) {
  $template_options = '';
  $attributes = [
    'id' => 'gridstack-regions',
  ];
  $attributes['class'][] = 'visually-hidden';
  if (empty($this->html5Ac)) {

    // @todo replace with core Awesomplete post 8.9+, see #3076171.
    $form['#attached']['library'][] = 'core/jquery.ui.autocomplete';
    $attributes['data-gs-regions'] = Json::encode(array_keys($this
      ->getRegionSuggestions()));
  }
  else {
    $options = [];
    foreach (array_keys($this
      ->getRegionSuggestions()) as $region) {
      $options[] = '<option>' . $region . '</option>';
    }
    $template_options = implode('', $options);
  }
  $form['regions'] = [
    '#markup' => '<template' . new Attribute($attributes) . '>' . $template_options . '</template>',
    '#allowed_tags' => [
      'template',
      'option',
    ],
    '#weight' => 100,
  ];
}