You are here

public function SlickSettingsForm::buildForm in Slick Carousel 8.2

Same name and namespace in other branches
  1. 8 slick_ui/src/Form/SlickSettingsForm.php \Drupal\slick_ui\Form\SlickSettingsForm::buildForm()
  2. 7.3 slick_ui/src/Form/SlickSettingsForm.php \Drupal\slick_ui\Form\SlickSettingsForm::buildForm()

Implements \Drupal\Core\Form\FormInterface::buildForm().

Overrides ConfigFormBase::buildForm

File

slick_ui/src/Form/SlickSettingsForm.php, line 50

Class

SlickSettingsForm
Defines the Slick admin settings form.

Namespace

Drupal\slick_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('slick.settings');
  $form['library'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Library to use'),
    '#description' => $this
      ->t('<a href=":url1">Slick</a> is the original library by Ken Wheeler. <a href=":url2">Accessible Slick</a> is a forked library with accessibility enhancements from Accessibility360. Be sure to clear cache if things broken when changing this. <b>Warning</b>! Accessible Slick has breaking changes, <a href=":url3">read more</a>.', [
      ':url1' => 'https://kenwheeler.github.io/slick/',
      ':url2' => 'https://accessible360.github.io/accessible-slick/',
      ':url3' => 'https://www.drupal.org/project/slick/issues/3196529',
    ]),
    '#options' => [
      'slick' => $this
        ->t('Slick'),
      'accessible-slick' => $this
        ->t('Accessible Slick'),
    ],
    '#default_value' => $config
      ->get('library'),
  ];
  $form['module_css'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable Slick module slick.theme.css'),
    '#description' => $this
      ->t('Uncheck to permanently disable the module slick.theme.css, normally included along with skins.'),
    '#default_value' => $config
      ->get('module_css'),
    '#prefix' => $this
      ->t("Note! Slick doesn't need Slick UI to run. It is always safe to uninstall Slick UI once done with optionsets."),
  ];
  $form['slick_css'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable Slick library slick-theme.css'),
    '#description' => $this
      ->t('Uncheck to permanently disable the optional slick-theme.css, normally included along with skins.'),
    '#default_value' => $config
      ->get('slick_css'),
  ];
  $form['disable_old_skins'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Disable deprecated skins'),
    '#description' => $this
      ->t('Deprecated skins are registered via the <a href=":url">to-be-deprecated hook_hook_info</a>. Now Slick uses plugin system to store its skins. Leave it unchecked if things are broken, or (y/our) sub-modules are not updated with the new plugin system, yet. If you are sure things are not broken, or never register a skin nor using Slick examples, you can check this to reduce extra join. At any rate, skins are permanently cached once, so should not impact much.', [
      ':url' => 'https://www.drupal.org/node/2233261',
    ]),
    '#default_value' => $config
      ->get('disable_old_skins'),
  ];
  $form['sitewide'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Load slick globally'),
    '#empty_option' => $this
      ->t('- None -'),
    '#options' => [
      1 => $this
        ->t('With default initializer'),
      2 => $this
        ->t('With vanilla initializer'),
      3 => $this
        ->t('Without initializer'),
    ],
    '#description' => $this
      ->t('Warning! Not compatible with BigPipe module due to assets re-ordering issue, see https://drupal.org/node/3211873. Meaning may break any stylings provided by this module.<ol><li><b>With default initializer</b> will include the module slick.load.min.js as the initializer normally used by the module formatters or views identified by <code>.slick</code> selector. Only if you need consistent styling/ skins, classes, media player, lightboxes, and markups. Works immediately at body texts.</li><li><b>With vanilla initializer</b> will include the module slick.vanilla.min.js as the minimal initializer identified by <code>.slick-vanilla</code> selector. Default skins, media player, lightboxes are unusable. Be sure to add CSS class <code>.slick-vanilla</code> to your Slick. Recommended to not interfere or co-exist with module formatters/ views. Works immediately at body texts.</li><li><b>Without initializer</b> will load only the main libraries. No module skins, no module JS. It is all yours -- broken unless you initialize it.</li></ol> This will include Slick anywhere except admin pages. Only do this if you need Slick where PHP or Twig is not available such as at body texts. Otherwise use the provided API instead. Implements <code>hook_slick_attach_alter</code> to include additional libraries such as skins, mousewheel, colorbox, etc. At any rate, you can inject options via <code>data-slick</code> attribute, or custom JavaScript. You can also include them at your theme, it is just a convenient way to avoid hard-coding at every theme changes. Check out slick.html.twig for more markups.'),
    '#default_value' => $config
      ->get('sitewide'),
  ];
  $default = $config
    ->get('sitewide') == 0 || $config
    ->get('sitewide') == 1;
  $form['preview'] = $default ? $this
    ->withInitializer() : $this
    ->withoutInitializer();
  return parent::buildForm($form, $form_state);
}