You are here

public function SiteSettingsConfigForm::buildForm in Site Settings and Labels 8

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/SiteSettingsConfigForm.php, line 65

Class

SiteSettingsConfigForm
Class SiteSettingsConfigForm.

Namespace

Drupal\site_settings\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('site_settings.config');

  // Global setting.
  $form['template_key'] = [
    '#type' => 'machine_name',
    '#title' => $this
      ->t('Template key'),
    '#description' => $this
      ->t('The key at which site settings should be made available in templates such as {{ site_settings.your_settings_group.your_setting_name }} with a template key of "site_settings".'),
    '#default_value' => $config
      ->get('template_key'),
    '#required' => TRUE,
    '#machine_name' => [
      'exists' => [
        $this,
        'machineNameExists',
      ],
    ],
  ];
  return parent::buildForm($form, $form_state);
}