You are here

public function PagererConfigForm::buildForm in Pagerer 8

Same name and namespace in other branches
  1. 8.2 src/Form/PagererConfigForm.php \Drupal\pagerer\Form\PagererConfigForm::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/PagererConfigForm.php, line 87

Class

PagererConfigForm
Main Pagerer settings admin form.

Namespace

Drupal\pagerer\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  // Add admin UI library.
  $form['#attached']['library'][] = 'pagerer/admin.ui';

  // Prepare fake pager for previews.
  $this->pagererFactory
    ->get(5)
    ->init(47884, 50);

  // Presets table.
  $form['presets'] = $this->presetsList
    ->render();

  // Container for global options.
  $form['pagerer'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t("General"),
  ];

  // Global option for pager override.
  $default_label = (string) $this
    ->t('Default:');
  $replace_label = (string) $this
    ->t('Replace with:');
  $options = [
    $default_label => [
      'core' => $this
        ->t('No - use Drupal core pager'),
    ],
    $replace_label => $this->presetsList
      ->listOptions(),
  ];
  $form['pagerer']['core_override_preset'] = [
    '#type' => 'select',
    '#title' => $this
      ->t("Replace standard pager"),
    '#description' => $this
      ->t("Core pager theme requests can be overridden. Select whether they need to be fulfilled by Drupal core pager, or the Pagerer pager to use."),
    '#options' => $options,
    '#default_value' => $this
      ->config('pagerer.settings')
      ->get('core_override_preset'),
  ];
  return parent::buildForm($form, $form_state);
}