You are here

public function CollapsiblockGlobalSettings::buildForm in Collapsiblock 4.x

Same name and namespace in other branches
  1. 8.2 src/Form/CollapsiblockGlobalSettings.php \Drupal\collapsiblock\Form\CollapsiblockGlobalSettings::buildForm()
  2. 8 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['default_action'] = [
    '#type' => 'radios',
    '#title' => t('Default block collapse behavior'),
    '#options' => unserialize(COLLAPSIBLOCK_ACTION_OPTIONS),
    '#default_value' => $config
      ->get('default_action'),
  ];
  $form['active_pages'] = [
    '#type' => 'checkbox',
    '#title' => t('Remember collapsed state on active pages'),
    '#default_value' => $config
      ->get('active_pages'),
    '#description' => t('Block can collapse even if it contains an active link (such as in menu blocks).'),
  ];
  $form['slide_type'] = [
    '#type' => 'radios',
    '#title' => t('Default animation type'),
    '#options' => [
      1 => t('Slide'),
      2 => t('Fade and slide'),
    ],
    '#description' => t('Slide is the Drupal default while Fade and slide adds a nice fade effect.'),
    '#default_value' => $config
      ->get('slide_type'),
  ];
  $options = [
    '50',
    '100',
    '200',
    '300',
    '400',
    '500',
    '700',
    '1000',
    '1300',
  ];
  $form['slide_speed'] = [
    '#type' => 'select',
    '#title' => t('Animation speed'),
    '#options' => array_combine($options, $options),
    '#description' => t('The animation speed in milliseconds.'),
    '#default_value' => $config
      ->get('slide_speed'),
  ];
  return parent::buildForm($form, $form_state);
}