--- /dev/null
+{% extends "base/class.php.twig" %}
+
+{% block file_path %}
+Drupal\{{module_name}}\Form\{{ class_name }}.
+{% endblock %}
+
+{% block namespace_class %}
+namespace Drupal\{{module_name}}\Form;
+{% endblock %}
+
+{% block use_class %}
+use Drupal\Core\Form\ConfigFormBase;
+use Drupal\Core\Form\FormStateInterface;
+{% if services is not empty %}
+use Drupal\Core\Config\ConfigFactoryInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+{% endif %}
+{% endblock %}
+
+{% block class_declaration %}
+/**
+ * Class {{ class_name }}.
+ *
+ * @package Drupal\{{module_name}}\Form
+ */
+class {{ class_name }} extends ConfigFormBase {% endblock %}
+{% block class_construct %}
+{% if services is not empty %}
+ public function __construct(
+ ConfigFactoryInterface $config_factory,
+ {{ servicesAsParameters(services)|join(',\n ') }}
+ ) {
+ parent::__construct($config_factory);
+ {{ serviceClassInitialization(services) }}
+ }
+
+{% endif %}
+{% endblock %}
+
+{% block class_create %}
+{% if services is not empty %}
+ public static function create(ContainerInterface $container) {
+ return new static(
+ $container->get('config.factory'),
+ {{ serviceClassInjection(services) }}
+ );
+ }
+
+{% endif %}
+{% endblock %}
+
+{% block class_methods %}
+ /**
+ * {@inheritdoc}
+ */
+ protected function getEditableConfigNames() {
+ return [
+ '{{module_name}}.{{class_name_short}}',
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFormId() {
+ return '{{form_id}}';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function buildForm(array $form, FormStateInterface $form_state) {
+ $config = $this->config('{{module_name}}.{{class_name_short}}');
+{% for input in inputs %}
+{% if input.fieldset is defined and input.fieldset is not empty %}
+ $form['{{ input.fieldset }}']['{{ input.name }}'] = [
+{% else %}
+ $form['{{ input.name }}'] = [
+{% endif %}
+ '#type' => '{{ input.type }}',
+ '#title' => $this->t('{{ input.label|e }}'),
+{% if input.description is defined and input.description is not empty %}
+ '#description' => $this->t('{{ input.description|e }}'),
+{% endif %}
+{% if input.options is defined and input.options is not empty %}
+ '#options' => {{ input.options }},
+{% endif %}
+{% if input.maxlength is defined and input.maxlength is not empty %}
+ '#maxlength' => {{ input.maxlength }},
+{% endif %}
+{% if input.size is defined and input.size is not empty %}
+ '#size' => {{ input.size }},
+{% endif %}
+{% if input.type != 'password_confirm' and input.type != 'fieldset' %}
+ '#default_value' => $config->get('{{ input.name }}'),
+{% endif %}
+ ];
+{% endfor %}
+ return parent::buildForm($form, $form_state);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function validateForm(array &$form, FormStateInterface $form_state) {
+ parent::validateForm($form, $form_state);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function submitForm(array &$form, FormStateInterface $form_state) {
+ parent::submitForm($form, $form_state);
+
+ $this->config('{{module_name}}.{{class_name_short}}')
+{% for input in inputs %}
+ ->set('{{ input.name }}', $form_state->getValue('{{ input.name }}'))
+{% endfor %}
+ ->save();
+ }
+{% endblock %}