You are here

public function DomainLangNegotiationSelectedForm::buildForm in Domain Lang 8

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 NegotiationSelectedForm::buildForm

File

src/Form/DomainLangNegotiationSelectedForm.php, line 64

Class

DomainLangNegotiationSelectedForm
Configure the selected language negotiation method for this site.

Namespace

Drupal\domain_lang\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config($this->languageNegotiationConfig);
  $form = parent::buildForm($form, $form_state);

  // Fill with initial values on first page visit.
  if (!$config
    ->get('selected_langcode')) {
    $config
      ->set('selected_langcode', $this
      ->config('language.negotiation')
      ->get('selected_langcode'));
  }
  if (isset($form['selected_langcode'])) {
    $form['selected_langcode']['#default_value'] = $config
      ->get('selected_langcode');
  }
  return $form;
}