You are here

public function MasqueradeForm::buildForm in Masquerade 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 FormInterface::buildForm

File

src/Form/MasqueradeForm.php, line 63

Class

MasqueradeForm
Form builder for the masquerade form.

Namespace

Drupal\masquerade\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['autocomplete'] = [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'container-inline',
      ],
    ],
  ];
  $form['autocomplete']['masquerade_as'] = [
    '#type' => 'entity_autocomplete',
    '#target_type' => 'user',
    '#selection_settings' => [
      'include_anonymous' => FALSE,
      'match_operator' => 'STARTS_WITH',
    ],
    '#title' => $this
      ->t('Username'),
    '#title_display' => 'invisible',
    '#required' => TRUE,
    '#placeholder' => $this
      ->t('Masquerade as…'),
    '#size' => '18',
  ];
  $form['autocomplete']['actions'] = [
    '#type' => 'actions',
  ];
  $form['autocomplete']['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Switch'),
  ];
  return $form;
}