You are here

public function SlickForm::getResponsiveFormElements in Slick Carousel 8.2

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

Defines available options for the responsive Slick.

Parameters

int $count: The number of breakpoints.

Return value

array An array of Slick responsive options.

1 call to SlickForm::getResponsiveFormElements()
SlickForm::form in slick_ui/src/Form/SlickForm.php
Gets the actual form array to be built.

File

slick_ui/src/Form/SlickForm.php, line 835

Class

SlickForm
Extends base form for slick instance configuration form.

Namespace

Drupal\slick_ui\Form

Code

public function getResponsiveFormElements($count = 0) {
  $elements = [];
  $range = range(0, $count - 1);
  $breakpoints = array_combine($range, $range);
  foreach ($breakpoints as $key => $breakpoint) {
    $elements[$key] = [
      'type' => 'details',
      'title' => $this
        ->t('Breakpoint #@key', [
        '@key' => $key + 1,
      ]),
    ];
    $elements[$key]['breakpoint'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('Breakpoint'),
      'description' => $this
        ->t('Breakpoint width in pixel. If mobileFirst enabled, equivalent to min-width, otherwise max-width.'),
      'default' => '',
      'field_suffix' => 'px',
    ];
    $elements[$key]['unslick'] = [
      'type' => 'checkbox',
      'title' => $this
        ->t('Unslick'),
      'description' => $this
        ->t("Disable Slick at a given breakpoint. Note, you can't window shrink this, once you unslick, you are unslicked."),
      'default' => FALSE,
    ];
    $elements[$key]['settings'] = [
      'type' => 'details',
      'title' => $this
        ->t('Settings'),
    ];

    // Duplicate relevant main settings.
    foreach ($this
      ->cleanFormElements() as $name => $responsive) {
      $elements[$key]['settings'][$name] = $responsive;
    }
  }
  return $elements;
}