You are here

public function PetSettingsForm::buildForm in Previewable email templates 8.3

Same name and namespace in other branches
  1. 8.4 src/Form/PetSettingsForm.php \Drupal\pet\Form\PetSettingsForm::buildForm()
  2. 8 src/Form/PetSettingsForm.php \Drupal\pet\Form\PetSettingsForm::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 FormInterface::buildForm

File

src/Form/PetSettingsForm.php, line 42

Class

PetSettingsForm
Class PetSettingsForm.

Namespace

Drupal\pet\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $pet_logging = \Drupal::config('pet.settings')
    ->get('pet_logging');
  $form['logging'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Pet log settings'),
    '#open' => TRUE,
  ];
  $options = [
    static::PET_LOGGER_ALL => $this
      ->t('Log everything.'),
    static::PET_LOGGER_ERRORS => $this
      ->t('Log errors only.'),
    static::PET_LOGGER_NONE => $this
      ->t('No logging, display error on screen.'),
  ];
  $form['logging']['pet_logging'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Log setting'),
    '#options' => $options,
    '#default_value' => $pet_logging,
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Submit'),
  ];
  return $form;
}