public function LingotekSettingsDefaultsForm::buildForm in Lingotek Translation 3.4.x
Same name and namespace in other branches
- 8 src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::buildForm()
- 8.2 src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::buildForm()
- 4.0.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::buildForm()
- 3.0.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::buildForm()
- 3.1.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::buildForm()
- 3.2.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::buildForm()
- 3.3.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::buildForm()
- 3.5.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::buildForm()
- 3.6.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::buildForm()
- 3.7.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::buildForm()
- 3.8.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::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/ LingotekSettingsDefaultsForm.php, line 70 
Class
- LingotekSettingsDefaultsForm
- Configure text display settings for this page.
Namespace
Drupal\lingotek\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
  $this
    ->init();
  foreach ($this->defaults_labels as $key => $label) {
    $resources_key = $key === 'subfilter' ? 'filter' : $key;
    asort($this->resources[$resources_key]);
    switch ($key) {
      case 'filter':
      case 'subfilter':
        $options = [
          'project_default' => $this
            ->t('Use Project Default'),
          'drupal_default' => $this
            ->t('Use Drupal Default'),
        ] + $this->resources[$resources_key];
        break;
      case 'workflow':
        $options = [
          'project_default' => $this
            ->t('Project Default'),
        ] + $this->resources[$resources_key];
        break;
      default:
        $options = $this->resources[$key];
        break;
    }
    $form[$key] = [
      '#title' => $label,
      '#type' => 'select',
      '#options' => $options,
      '#required' => TRUE,
    ];
    if (isset($this->defaults[$key])) {
      $form[$key]['#default_value'] = $this->defaults[$key];
    }
  }
  return parent::buildForm($form, $form_state);
}