You are here

public function CollapsiblockGlobalSettings::buildForm in Collapsiblock 8

Same name and namespace in other branches
  1. 8.2 src/Form/CollapsiblockGlobalSettings.php \Drupal\collapsiblock\Form\CollapsiblockGlobalSettings::buildForm()
  2. 4.x src/Form/CollapsiblockGlobalSettings.php \Drupal\collapsiblock\Form\CollapsiblockGlobalSettings::buildForm()
  3. 3.x src/Form/CollapsiblockGlobalSettings.php \Drupal\collapsiblock\Form\CollapsiblockGlobalSettings::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/CollapsiblockGlobalSettings.php, line 34

Class

CollapsiblockGlobalSettings
Class CollapsiblockGlobalSettings.

Namespace

Drupal\collapsiblock\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('collapsiblock.settings');
  $form['collapsiblock_default_state'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Default block collapse behavior'),
    '#options' => [
      1 => $this
        ->t('None.'),
      2 => $this
        ->t('Collapsible, expanded by default.'),
      3 => $this
        ->t('Collapsible, collapsed by default.'),
      4 => $this
        ->t('Collapsible, collapsed all the time.'),
    ],
    '#default_value' => $config
      ->get('default_state'),
  ];
  $form['collapsiblock_active_pages'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Remember collapsed state on active pages'),
    '#default_value' => $config
      ->get('active_pages'),
    '#description' => $this
      ->t('Block can collapse even if it contains an active link (such as in menu blocks).'),
  ];
  $form['collapsiblock_slide_type'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Default animation type'),
    '#options' => [
      1 => $this
        ->t('Slide'),
      2 => $this
        ->t('Fade and slide'),
    ],
    '#description' => $this
      ->t('Slide is the Drupal default while Fade and slide adds a nice fade effect.'),
    '#default_value' => $config
      ->get('slide_type'),
  ];
  $form['collapsiblock_slide_speed'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Animation speed'),
    '#options' => [
      '0' => '0',
      '50' => '50',
      '100' => '100',
      '200' => '200',
      '300' => '300',
      '400' => '400',
      '500' => '500',
      '700' => '700',
      '1000' => '1000',
      '1300' => '1300',
    ],
    '#description' => $this
      ->t('The animation speed in milliseconds.'),
    '#default_value' => $config
      ->get('slide_speed'),
  ];
  $form['collapsiblock_help'] = [
    '#markup' => $this
      ->t('If collapsiblock doesn\'t work out of the box, you can force CSS selectors on <a href="adadad">appearance settings</a>.'),
  ];
  return parent::buildForm($form, $form_state);
}