You are here

public function LoqateApiKeyConfigForm::buildForm in Loqate 8

Same name and namespace in other branches
  1. 2.x src/Form/LoqateApiKeyConfigForm.php \Drupal\loqate\Form\LoqateApiKeyConfigForm::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 ConfigFormBase::buildForm

File

src/Form/LoqateApiKeyConfigForm.php, line 39

Class

LoqateApiKeyConfigForm
Class LoqateApiKeyConfigForm.

Namespace

Drupal\loqate\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('loqate.loqateapikeyconfig');
  $read_more_url = Url::fromUri('https://www.loqate.com/resources/support/setup-guides/advanced-setup-guide/#creating_a_key');
  $description_read_more_link = Link::fromTextAndUrl('Read more about the Loqate API.', $read_more_url)
    ->toString();
  $form[self::DEFAULT_API_KEY] = [
    '#type' => 'key_select',
    '#title' => $this
      ->t('Default Loqate API key'),
    '#description' => $description_read_more_link,
    '#default_value' => $config
      ->get(self::DEFAULT_API_KEY),
  ];
  $doc_link = Link::fromTextAndUrl('Security', Url::fromUri('https://www.loqate.com/resources/support/setup-guides/advanced-setup-guide/#security'));
  $doc_markup = $this
    ->t('<strong>Important:</strong> See Loqate\'s @link section for more details about keeping your Loqate API key secure!', [
    '@link' => $doc_link
      ->toString(),
  ]);
  $form['information'] = [
    '#markup' => '<p>' . $doc_markup . '</p>',
  ];
  return parent::buildForm($form, $form_state);
}