You are here

public function GridStackAdmin::openingForm in GridStack 8.2

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

Returns the opening form elements.

1 call to GridStackAdmin::openingForm()
GridStackAdmin::buildSettingsForm in src/Form/GridStackAdmin.php
Returns all settings form elements.

File

src/Form/GridStackAdmin.php, line 100

Class

GridStackAdmin
Provides reusable admin functions or form elements.

Namespace

Drupal\gridstack\Form

Code

public function openingForm(array &$form, &$definition = []) {
  $path = drupal_get_path('module', 'gridstack');
  $is_ui = $this
    ->manager()
    ->getModuleHandler()
    ->moduleExists('gridstack_ui');
  $is_help = $this
    ->manager()
    ->getModuleHandler()
    ->moduleExists('help');
  $route = [
    'name' => 'gridstack_ui',
  ];
  $readme = $is_ui && $is_help ? Url::fromRoute('help.page', $route)
    ->toString() : Url::fromUri('base:' . $path . '/README.md')
    ->toString();
  if (!isset($form['optionset'])) {
    $this->blazyAdmin
      ->openingForm($form, $definition);
    if ($is_ui) {
      $route_name = 'entity.gridstack.collection';
      $form['optionset']['#description'] = $this
        ->t('Manage optionsets at <a href=":url" target="_blank">the optionset admin page</a>.', [
        ':url' => Url::fromRoute($route_name)
          ->toString(),
      ]);
    }
  }
  if (isset($form['skin'])) {
    $form['skin']['#description'] = $this
      ->t('Skins allow various layouts with just CSS. Some options below depend on a skin. Leave empty to DIY. Check out <a href=":url">docs to register skins</a>.', [
      ':url' => $readme,
    ]);
  }
  $form['gridnative'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Use native CSS Grid'),
    '#description' => $this
      ->t('<b>Experimental!</b> Check to replace any js-driven (gridstack, masonry, packery, isotope) layouts with native browser Grid layout. Check out <a href=":url">CSS Grid browser supports</a> relevant to your visitors. <br>Uncheck if any issue.', [
      ':url' => 'https://caniuse.com/#feat=css-grid',
    ]),
  ];
  if (isset($form['background'])) {
    $form['background']['#description'] = $this
      ->t('Only if troubled with image sizes not making the given box gapless, check this to turn the image into CSS background instead. Blazy formatter only.');
    $form['background']['#weight'] = -40;
  }
}