You are here

public function GridStackLayoutTrait::buildFormElements in GridStack 8

2 calls to GridStackLayoutTrait::buildFormElements()
GridStackLayout::buildConfigurationForm in src/Layout/GridStackLayout.php
Form constructor.
GridStackLayoutDeprecated::buildConfigurationForm in src/Layout/GridStackLayoutDeprecated.php
Form constructor.

File

src/Layout/GridStackLayoutTrait.php, line 88

Class

GridStackLayoutTrait
A Trait common for optional layout integration.

Namespace

Drupal\gridstack\Layout

Code

public function buildFormElements(array $settings = []) {
  $wrapper_options = [
    'div' => 'Div',
    'article' => 'Article',
    'aside' => 'Aside',
    'figure' => 'Figure',
    'header' => 'Header',
    'main' => 'Main',
    'footer' => 'Footer',
    'section' => 'Section',
  ];
  $elements['wrapper'] = [
    '#type' => 'select',
    '#options' => $wrapper_options,
    '#title' => $this
      ->t('Wrapper'),
    '#default_value' => isset($settings['wrapper']) ? $settings['wrapper'] : 'div',
  ];
  $elements['wrapper_classes'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Classes'),
    '#description' => $this
      ->t('E.g.: text-left text-lowercase no-gutters'),
    '#default_value' => isset($settings['wrapper_classes']) ? $settings['wrapper_classes'] : '',
  ];
  $elements['attributes'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Attributes'),
    '#description' => $this
      ->t('E.g.: role|navigation,data-something|some value'),
    '#default_value' => isset($settings['attributes']) ? strip_tags($settings['attributes']) : '',
    '#weight' => 20,
  ];
  return $elements;
}