You are here

public function ModuleFilterUpdateStatusForm::buildForm in Module Filter 8.3

Same name and namespace in other branches
  1. 8 src/Form/ModuleFilterUpdateStatusForm.php \Drupal\module_filter\Form\ModuleFilterUpdateStatusForm::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 FormInterface::buildForm

File

src/Form/ModuleFilterUpdateStatusForm.php, line 23

Class

ModuleFilterUpdateStatusForm
A form for filtering the update status report page.

Namespace

Drupal\module_filter\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['filters'] = [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'table-filter',
        'js-show',
      ],
    ],
  ];
  $form['filters']['text'] = [
    '#type' => 'search',
    '#title' => $this
      ->t('Filter projects'),
    '#title_display' => 'invisible',
    '#size' => 30,
    '#placeholder' => $this
      ->t('Filter by name'),
    '#attributes' => [
      'class' => [
        'table-filter-text',
      ],
      'data-table' => '#update-status',
      'autocomplete' => 'off',
    ],
    '#attached' => [
      'library' => [
        'module_filter/update.status',
      ],
    ],
  ];
  if (!empty($_GET['filter'])) {
    $form['filters']['text']['#default_value'] = $_GET['filter'];
  }
  $form['filters']['radios'] = [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'module-filter-status',
      ],
    ],
    'show' => [
      '#type' => 'radios',
      '#default_value' => 'all',
      '#options' => [
        'all' => $this
          ->t('All'),
        'updates' => $this
          ->t('Update available'),
        'security' => $this
          ->t('Security update'),
      ],
    ],
  ];
  return $form;
}