3 namespace Drupal\better_formats\Form;
5 use Drupal\Core\Form\ConfigFormBase;
6 use Drupal\Core\Form\FormStateInterface;
11 * @package Drupal\better_formats\Form
13 class SettingsForm extends ConfigFormBase {
18 public function getFormId() {
19 return 'better_formats_settings_form';
25 protected function getEditableConfigNames() {
26 return ['better_formats.settings'];
32 public function buildForm(array $form, FormStateInterface $form_state) {
33 $config = $this->config('better_formats.settings');
36 '#type' => 'fieldset',
37 '#title' => t('Control'),
40 $form['control']['per_field_core'] = [
41 '#type' => 'checkbox',
42 '#title' => t('Use field default'),
43 '#description' => t('Use the core field module default value to set the default format. This will force the default format even when the default field value is empty. To set a default format you must re-edit a text field after saving it with the "Filtered text" option turned on.'),
44 '#default_value' => $config->get('per_field_core'),
47 return parent::buildForm($form, $form_state);
53 public function submitForm(array &$form, FormStateInterface $form_state) {
54 $config = $this->config('better_formats.settings');
55 $form_state->cleanValues();
57 foreach ($form_state->getValues() as $key => $value) {
58 $config->set($key, $value);
62 parent::submitForm($form, $form_state);