You are here

public function BasicAuthTrait::buildConfigurationForm in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/SolrConnector/BasicAuthTrait.php \Drupal\search_api_solr\SolrConnector\BasicAuthTrait::buildConfigurationForm()
  2. 8.2 src/SolrConnector/BasicAuthTrait.php \Drupal\search_api_solr\SolrConnector\BasicAuthTrait::buildConfigurationForm()

File

src/SolrConnector/BasicAuthTrait.php, line 28

Class

BasicAuthTrait
Basic auth functionality for a Solr connector.

Namespace

Drupal\search_api_solr\SolrConnector

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildConfigurationForm($form, $form_state);
  $form['auth'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('HTTP Basic Authentication'),
    '#description' => $this
      ->t('If your Solr server is protected by basic HTTP authentication, enter the login data here.'),
    '#collapsible' => TRUE,
    '#collapsed' => empty($this->configuration['username']),
  ];
  $form['auth']['username'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Username'),
    '#default_value' => $this->configuration['username'],
    '#required' => TRUE,
  ];
  $form['auth']['password'] = [
    '#type' => 'password',
    '#title' => $this
      ->t('Password'),
    '#description' => $this
      ->t('If this field is left blank and the HTTP username is filled out, the current password will not be changed.'),
  ];
  $form_state
    ->set('previous_password', $this->configuration['password']);
  return $form;
}