Form.html.twig in Drupal 7 to 8/9 Module Upgrader 8
Contains \Drupal\{{ module }}\Form\{{ class }}.
File
templates/Form.html.twigView source
- <?php
-
- /**
- * @file
- * Contains \Drupal\{{ module }}\Form\{{ class }}.
- */
-
- namespace Drupal\{{ module }}\Form;
-
- use Drupal\Core\Form\{% if config %}Config{% endif %}FormBase;
- use Drupal\Core\Form\FormStateInterface;
- use Drupal\Core\Render\Element;
-
- class {{ class }} extends {% if config %}Config{% endif %}FormBase {
-
- /**
- * {@inheritdoc}
- */
- public function getFormId() {
- return '{{ form_id }}';
- }
-
- {% if config %}
- /**
- * {@inheritdoc}
- */
- public function submitForm(array &$form, FormStateInterface $form_state) {
- $config = $this->config('{{ module }}.settings');
-
- foreach (Element::children($form) as $variable) {
- $config->set($variable, $form_state->getValue($form[$variable]['#parents']));
- }
- $config->save();
-
- if (method_exists($this, '_submitForm')) {
- $this->_submitForm($form, $form_state);
- }
-
- parent::submitForm($form, $form_state);
- }
-
- /**
- * {@inheritdoc}
- */
- protected function getEditableConfigNames() {
- return ['{{ module }}.settings'];
- }
- {% endif %}
-
- }
- ?>