NegotiationConfigureForm::buildForm

public NegotiationConfigureForm::buildForm(array $form, FormStateInterface $form_state)

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

core/modules/language/src/Form/NegotiationConfigureForm.php, line 124

Class

NegotiationConfigureForm
Configure the selected language negotiation method for this site.

Namespace

Drupal\language\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $configurable = $this->languageTypes->get('configurable');

  $form = array(
    '#theme' => 'language_negotiation_configure_form',
    '#language_types_info' => $this->languageManager->getDefinedLanguageTypesInfo(),
    '#language_negotiation_info' => $this->negotiator->getNegotiationMethods(),
  );
  $form['#language_types'] = array();

  foreach ($form['#language_types_info'] as $type => $info) {
    // Show locked language types only if they are configurable.
    if (empty($info['locked']) || in_array($type, $configurable)) {
      $form['#language_types'][] = $type;
    }
  }

  foreach ($form['#language_types'] as $type) {
    $this->configureFormTable($form, $type);
  }

  $form['actions'] = array('#type' => 'actions');
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#button_type' => 'primary',
    '#value' => $this->t('Save settings'),
  );

  return $form;
}
doc_Drupal
2016-10-29 09:30:00
Comments
Leave a Comment

Please login to continue.