public function PagererUrlConfigForm::buildForm in Pagerer 8.2
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/ PagererUrlConfigForm.php, line 30 
Class
- PagererUrlConfigForm
- Main Pagerer URL settings admin form.
Namespace
Drupal\pagerer\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('pagerer.settings');
  $form['pagerer']['core_override_querystring'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('URL querystring'),
    '#description' => $this
      ->t('Pagerer overrides the standard URL querystring "page" key.'),
    '#default_value' => (bool) $config
      ->get('url_querystring.core_override'),
  ];
  $form['pagerer']['querystring_key'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Querystring key'),
    '#description' => $this
      ->t('The key to be used in the URL querystring, in place of "page". For example, "pg".'),
    '#default_value' => $config
      ->get('url_querystring.querystring_key'),
    '#required' => TRUE,
    '#size' => 6,
    '#maxlength' => 10,
    '#states' => [
      'enabled' => [
        ':input[name="core_override_querystring"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $options = [
    0 => $this
      ->t('Zero-based'),
    1 => $this
      ->t('One-based'),
  ];
  $form['pagerer']['index_base'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Page index base'),
    '#description' => $this
      ->t('The number base for the page index in the URL querystring.'),
    '#default_value' => $config
      ->get('url_querystring.index_base'),
    '#options' => $options,
    '#states' => [
      'enabled' => [
        ':input[name="core_override_querystring"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  return parent::buildForm($form, $form_state);
}