You are here

public function ProfilesFilterForm::buildForm in Devel 8.3

Same name and namespace in other branches
  1. 8 webprofiler/src/Form/ProfilesFilterForm.php \Drupal\webprofiler\Form\ProfilesFilterForm::buildForm()
  2. 8.2 webprofiler/src/Form/ProfilesFilterForm.php \Drupal\webprofiler\Form\ProfilesFilterForm::buildForm()
  3. 4.x webprofiler/src/Form/ProfilesFilterForm.php \Drupal\webprofiler\Form\ProfilesFilterForm::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

webprofiler/src/Form/ProfilesFilterForm.php, line 24

Class

ProfilesFilterForm
Class ProfilesFilterForm.

Namespace

Drupal\webprofiler\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['ip'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('IP'),
    '#size' => 30,
    '#default_value' => $this
      ->getRequest()->query
      ->get('ip'),
    '#prefix' => '<div class="form--inline clearfix">',
  ];
  $form['url'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Url'),
    '#size' => 30,
    '#default_value' => $this
      ->getRequest()->query
      ->get('url'),
  ];
  $form['method'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Method'),
    '#options' => [
      'GET' => 'GET',
      'POST' => 'POST',
    ],
    '#default_value' => $this
      ->getRequest()->query
      ->get('method'),
  ];
  $limits = [
    10,
    50,
    100,
  ];
  $form['limit'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Limit'),
    '#options' => array_combine($limits, $limits),
    '#default_value' => $this
      ->getRequest()->query
      ->get('limit'),
  ];
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['filter'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Filter'),
    '#attributes' => [
      'class' => [
        'button--primary',
      ],
    ],
    '#suffix' => '</div>',
  ];
  return $form;
}