You are here

public function LanguageMappingEditForm::buildForm in Flags 8

@inheritDoc

Overrides LanguageConfigEntityFormBase::buildForm

File

flags_ui/src/Form/LanguageMappingEditForm.php, line 41

Class

LanguageMappingEditForm
Class FlagMappingEditForm

Namespace

Drupal\flags_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  /** @var FlagMapping $mapping */
  $mapping = $this->entity;
  $allLanguages = $this->languageManager
    ->getAllDefinedLanguages();
  $id = $mapping
    ->getSource();
  $row['language'] = $form['title'] = [
    '#type' => 'item',
    '#markup' => isset($allLanguages[$id]) ? $allLanguages[$id] : $id,
  ];
  $form = parent::buildForm($form, $form_state);

  // We do not allow editing of source language which is entity's ID.
  $form['source'] = [
    '#type' => 'value',
    '#value' => $mapping
      ->getSource(),
  ];
  return $form;
}