You are here

public function Referers::buildForm in Visitors 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 DateFilter::buildForm

File

src/Form/Referers.php, line 13

Class

Referers

Namespace

Drupal\visitors\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $this
    ->_setSessionRefererType();
  $form = parent::buildForm($form, $form_state);
  unset($form['submit']);
  $form['visitors_referer'] = array(
    '#type' => 'fieldset',
    '#title' => t('Referers type filter'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
    '#description' => t('Choose referers type'),
  );
  $form['visitors_referer']['referer_type'] = array(
    '#type' => 'select',
    '#title' => 'Referer type',
    '#default_value' => $_SESSION['referer_type'],
    '#options' => array(
      REFERER_TYPE_INTERNAL_PAGES => t('Internal pages'),
      REFERER_TYPE_EXTERNAL_PAGES => t('External pages'),
      REFERER_TYPE_ALL_PAGES => t('All pages'),
    ),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}