<commit_before>{% 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\FormBase;
use Drupal\Core\Form\FormStateInterface;
{% if services is not empty %}
use Symfony\Component\DependencyInjection\ContainerInterface;
{% endif %}
{% endblock %}

{% block class_declaration %}
/**
 * Class {{ class_name }}.
 *
 * @package Drupal\{{module_name}}\Form
 */
class {{ class_name }} extends FormBase {% endblock %}
{% block class_construct %}
{% if services is not empty %}
  /**
   * Constructs a new {{ class_name }} object.
   */
  public function __construct(
    {{ servicesAsParameters(services)|join(',\n    ') }}
  ) {
{{ serviceClassInitialization(services) }}
  }

{% endif %}
{% endblock %}

{% block class_create %}
{% if services is not empty %}
  public static function create(ContainerInterface $container) {
    return new static(
{{ serviceClassInjection(services) }}
    );
  }

{% endif %}
{% endblock %}

{% block class_methods %}

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return '{{form_id}}';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
{% for input in inputs %}
{% if input.fieldset|length %}
    $form['{{ input.fieldset }}']['{{ input.name }}'] = [
{% else %}
    $form['{{ input.name }}'] = [
{% endif %}
      '#type' => '{{ input.type }}',
      '#title' => $this->t('{{ input.label|e }}'),
{% if input.description|length %}
      '#description' => $this->t('{{ input.description|e }}'),
{% endif %}
{% if input.options|length %}
      '#options' => {{ input.options }},
{% endif %}
{% if input.maxlength|length %}
      '#maxlength' => {{ input.maxlength }},
{% endif %}
{% if input.size|length %}
      '#size' => {{ input.size }},
{% endif %}
    ];
{% endfor %}

    $form['submit'] = [
        '#type' => 'submit',
        '#value' => $this->t('Submit'),
    ];

    return $form;
  }

  /**
    * {@inheritdoc}
    */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    parent::validateForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    // Display result.
    foreach ($form_state->getValues() as $key => $value) {
        drupal_set_message($key . ': ' . $value);
    }

  }
{% endblock %}<commit_msg>Fix whitespace in generated forms. (#3245)<commit_after>{% 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\FormBase;
use Drupal\Core\Form\FormStateInterface;
{% if services is not empty %}
use Symfony\Component\DependencyInjection\ContainerInterface;
{% endif %}
{% endblock %}

{% block class_declaration %}
/**
 * Class {{ class_name }}.
 *
 * @package Drupal\{{module_name}}\Form
 */
class {{ class_name }} extends FormBase {% endblock %}
{% block class_construct %}
{% if services is not empty %}
  /**
   * Constructs a new {{ class_name }} object.
   */
  public function __construct(
    {{ servicesAsParameters(services)|join(',\n    ') }}
  ) {
{{ serviceClassInitialization(services) }}
  }

{% endif %}
{% endblock %}

{% block class_create %}
{% if services is not empty %}
  public static function create(ContainerInterface $container) {
    return new static(
{{ serviceClassInjection(services) }}
    );
  }

{% endif %}
{% endblock %}

{% block class_methods %}

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return '{{form_id}}';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
{% for input in inputs %}
{% if input.fieldset|length %}
    $form['{{ input.fieldset }}']['{{ input.name }}'] = [
{% else %}
    $form['{{ input.name }}'] = [
{% endif %}
      '#type' => '{{ input.type }}',
      '#title' => $this->t('{{ input.label|e }}'),
{% if input.description|length %}
      '#description' => $this->t('{{ input.description|e }}'),
{% endif %}
{% if input.options|length %}
      '#options' => {{ input.options }},
{% endif %}
{% if input.maxlength|length %}
      '#maxlength' => {{ input.maxlength }},
{% endif %}
{% if input.size|length %}
      '#size' => {{ input.size }},
{% endif %}
    ];
{% endfor %}
    $form['submit'] = [
      '#type' => 'submit',
      '#value' => $this->t('Submit'),
    ];

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    parent::validateForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    // Display result.
    foreach ($form_state->getValues() as $key => $value) {
      drupal_set_message($key . ': ' . $value);
    }

  }
{% endblock %}
{'fraction_non_alphanumeric': 0.20235756385068762, 'fraction_numerical': 0.0007858546168958742, 'mean_word_length': 3.3963730569948187, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '398147', 'n_tokens_mistral': 1779, 'n_tokens_neox': 1627, 'n_words': 333}