You are here

public function PopupAdminForm::buildForm in Popup 8

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/PopupAdminForm.php, line 90
Contains \Drupal\popup\src\Form\PopupAdminForm.

Class

PopupAdminForm
Class PopupAdminForm.

Namespace

Drupal\popup\Form

Code

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

  // Get current user data.
  $uid = $this->currentUser
    ->id();
  $this->messenger
    ->addMessage('Title: ' . $form_state
    ->getValue('title') . ', User UID: ' . $uid);
  $form['search_by_page_number_of_items'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Number of items to index per cron run'),
    '#options' => [
      10 => '10',
      20 => '20',
      50 => '50',
      100 => '100',
      200 => '200',
      500 => '500',
    ],
    '#default_value' => $this->configFactory
      ->get('search_by_page_number_of_items'),
    '#description' => $this
      ->t('The maximum number of items indexed in each pass of a :reports by Search by Page.', [
      ':reports' => 'cron maintenance task',
    ]),
    '#weight' => 1,
  ];
  $form['search_by_page_env'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Default environment'),
    '#options' => [
      1 => $this
        ->t('One'),
      2 => $this
        ->t('Two'),
      3 => $this
        ->t('Three'),
    ],
    '#default_value' => $this->configFactory
      ->get('search_by_page_env'),
    '#description' => $this
      ->t('The default environment is used for the Search by Page tab when using the core Search page.'),
    '#weight' => 2,
  ];
  $form['search_by_page_tab'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Search tab name'),
    '#default_value' => $this->configFactory
      ->get('search_by_page_tab') ?? $this
      ->t('Pages'),
    '#description' => $this
      ->t('If using Search by Page with the core Search module, the name of the tab where Search by Page results are shown.'),
    '#weight' => 2,
  ];
  return parent::buildForm($form, $form_state);
}