You are here

public function LingotekSettingsTabProfilesEditForm::buildForm in Lingotek Translation 8

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

Class

LingotekSettingsTabProfilesEditForm
Configure Lingotek

Namespace

Drupal\lingotek\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $this
    ->retrieveProfileFromUrl();
  $this
    ->retrieveProfileVaults();
  $this
    ->retrieveEnabledSettings();
  $form['defaults']['name'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Profile Name'),
    '#default_value' => $this
      ->t(ucwords($this->profile['name'])),
    '#disabled' => $this->profile_name_disabled,
  );
  $form['defaults']['current_future_note'] = array(
    '#type' => 'markup',
    '#markup' => '<h3>' . t('Profile settings impacting all entities (new and existing)') . '</h3><hr />',
  );
  $form['defaults']['auto_upload'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Upload Content Automatically'),
    '#description' => $this
      ->t('When enabled, your Drupal content (including saved edits) will automatically be uploaded to Lingotek for translation. When disabled, you are required to manually upload your content by clicking the "Upload" button on the Translations tab.'),
    '#disabled' => $this->auto_upload_disabled,
    '#default_value' => $this->profile['auto_upload'],
  );
  $form['defaults']['auto_download'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Download Translations Automatically'),
    '#description' => $this
      ->t('When enabled, completed translations will automatically be downloaded from Lingotek. When disabled, you are required to manually download translations by clicking the "Download" button on the Translations tab.'),
    '#disabled' => $this->auto_download_disabled,
    '#default_value' => $this->profile['auto_download'],
  );
  $form['defaults']['future_only_note'] = array(
    '#type' => 'markup',
    '#markup' => '<h3>' . $this
      ->t('Profile settings impacting only new nodes') . '</h3><hr />',
  );
  $form['defaults']['vault'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Default Vault'),
    '#options' => $this->profile_vaults,
    '#description' => $this
      ->t('The default Translation Memory Vault where translations are saved.'),
    '#default_value' => FALSE,
  );
  $form['defaults']['actions']['#type'] = 'actions';
  $form['defaults']['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => $this
      ->t('Save'),
    '#button_type' => 'primary',
  );
  $form['defaults']['actions']['cancel'] = array(
    '#type' => 'submit',
    '#value' => $this
      ->t('Cancel'),
    '#button_type' => 'primary',
    '#submit' => array(
      '::cancel',
    ),
  );

  // User cannot delete a non-custom profile
  if (!$this->is_custom_id) {
    $form['defaults']['actions']['cant_delete_button'] = array(
      '#type' => 'submit',
      '#value' => $this
        ->t('This profile cannot be deleted'),
      '#button_type' => 'primary',
      '#disabled' => TRUE,
    );
  }
  elseif ($this->profile_usage > 0 and $this->is_custom_id) {
    $form['defaults']['actions']['cant_delete_usage_button'] = array(
      '#type' => 'submit',
      '#value' => $this
        ->t('You can only delete this profile when there are no entities or bundles using it'),
      '#button_type' => 'primary',
      '#disabled' => TRUE,
    );
  }
  else {
    $form['defaults']['actions']['delete'] = array(
      '#type' => 'submit',
      '#value' => $this
        ->t('Delete'),
      '#button_type' => 'primary',
      '#submit' => array(
        '::deleteButton',
      ),
    );
  }
  return $form;
}