You are here

public function LingotekSettingsCommunityForm::buildForm in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8 src/Form/LingotekSettingsCommunityForm.php \Drupal\lingotek\Form\LingotekSettingsCommunityForm::buildForm()
  2. 8.2 src/Form/LingotekSettingsCommunityForm.php \Drupal\lingotek\Form\LingotekSettingsCommunityForm::buildForm()
  3. 4.0.x src/Form/LingotekSettingsCommunityForm.php \Drupal\lingotek\Form\LingotekSettingsCommunityForm::buildForm()
  4. 3.0.x src/Form/LingotekSettingsCommunityForm.php \Drupal\lingotek\Form\LingotekSettingsCommunityForm::buildForm()
  5. 3.1.x src/Form/LingotekSettingsCommunityForm.php \Drupal\lingotek\Form\LingotekSettingsCommunityForm::buildForm()
  6. 3.2.x src/Form/LingotekSettingsCommunityForm.php \Drupal\lingotek\Form\LingotekSettingsCommunityForm::buildForm()
  7. 3.3.x src/Form/LingotekSettingsCommunityForm.php \Drupal\lingotek\Form\LingotekSettingsCommunityForm::buildForm()
  8. 3.5.x src/Form/LingotekSettingsCommunityForm.php \Drupal\lingotek\Form\LingotekSettingsCommunityForm::buildForm()
  9. 3.6.x src/Form/LingotekSettingsCommunityForm.php \Drupal\lingotek\Form\LingotekSettingsCommunityForm::buildForm()
  10. 3.7.x src/Form/LingotekSettingsCommunityForm.php \Drupal\lingotek\Form\LingotekSettingsCommunityForm::buildForm()
  11. 3.8.x src/Form/LingotekSettingsCommunityForm.php \Drupal\lingotek\Form\LingotekSettingsCommunityForm::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/LingotekSettingsCommunityForm.php, line 22

Class

LingotekSettingsCommunityForm
Configure text display settings for this page.

Namespace

Drupal\lingotek\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $config = $this->configFactory
    ->get('lingotek.settings');
  $community_id = $config
    ->get('default.community');
  $communities = $this->lingotek
    ->getCommunities();
  $form['lingotek_user_directions_1'] = [
    '#markup' => '<p>' . t('Your account is associated with multiple Lingotek communities.') . '</p>
      <p>' . t('Select the community that you would like associate with this site:') . '</p>',
  ];
  $community_options = [];
  foreach ($communities as $id => $name) {
    $community_options[$id] = $name . ' (' . $id . ')';
  }
  asort($community_options);
  $form['community'] = [
    '#title' => t('Community'),
    '#type' => 'select',
    '#options' => $community_options,
    '#default_value' => $community_id,
    '#required' => TRUE,
  ];
  $form['lingotek_communities'] = [
    '#type' => 'hidden',
    '#value' => json_encode($communities),
  ];

  // Provide new button to continue
  $form['actions']['submit']['#value'] = t('Next');
  return $form;
}