PetSettingsForm.php in Previewable email templates 8
File
src/Form/PetSettingsForm.php
View source
<?php
namespace Drupal\pet\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class PetSettingsForm extends FormBase {
public function getFormId() {
return 'pet_settings';
}
public function submitForm(array &$form, FormStateInterface $form_state) {
\Drupal::configFactory()
->getEditable('pet.settings')
->set('pet_logging', $form_state
->getValue('pet_logging'))
->save();
}
public function buildForm(array $form, FormStateInterface $form_state) {
$pet_logging = \Drupal::config('pet.settings')
->get('pet_logging');
$form['logging'] = array(
'#type' => 'details',
'#title' => t('PET log settings'),
'#open' => TRUE,
);
$options = array(
0 => t('Log everything.'),
1 => t('Log errors only.'),
2 => t('No logging, display error on screen, useful for debugging.'),
);
$form['logging']['pet_logging'] = array(
'#type' => 'radios',
'#title' => t('Log setting'),
'#options' => $options,
'#default_value' => $pet_logging,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}
}