From 22490f237465138d3a72a8975c82a28de905fb95 Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Sat, 6 Apr 2019 16:17:39 -0600 Subject: [PATCH] Fix coding standards for generate:form command. (#3900) --- src/Generator/FormGenerator.php | 2 +- templates/module/routing-form.yml.twig | 3 +-- templates/module/src/Form/form.php.twig | 9 ++++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Generator/FormGenerator.php b/src/Generator/FormGenerator.php index 957c6bb4f..71325c57f 100644 --- a/src/Generator/FormGenerator.php +++ b/src/Generator/FormGenerator.php @@ -80,7 +80,7 @@ public function generate(array $parameters) $moduleInstance->getFormPath() . '/' . $class_name . '.php', $parameters ); - + // Render defaults YML file. if ($config_file == true) { $this->renderFile( diff --git a/templates/module/routing-form.yml.twig b/templates/module/routing-form.yml.twig index f387bc058..d590fa707 100644 --- a/templates/module/routing-form.yml.twig +++ b/templates/module/routing-form.yml.twig @@ -13,6 +13,5 @@ {% else %} requirements: _access: 'TRUE' - {% endif %} {% endif %} - +{% endif %} diff --git a/templates/module/src/Form/form.php.twig b/templates/module/src/Form/form.php.twig index 8917a81b4..8bcae4455 100644 --- a/templates/module/src/Form/form.php.twig +++ b/templates/module/src/Form/form.php.twig @@ -21,8 +21,10 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * Class {{ class_name }}. */ class {{ class_name }} extends FormBase {% endblock %} + {% block class_construct %} {% if services is not empty %} + /** * Constructs a new {{ class_name }} object. */ @@ -37,12 +39,14 @@ class {{ class_name }} extends FormBase {% endblock %} {% block class_create %} {% if services is not empty %} + /** + * {@inheritdoc} + */ public static function create(ContainerInterface $container) { return new static( {{ serviceClassInjection(services) }} ); } - {% endif %} {% endblock %} @@ -99,6 +103,9 @@ class {{ class_name }} extends FormBase {% endblock %} * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { + foreach ($form_state->getValues() as $key => $value) { + // @TODO: Validate fields. + } parent::validateForm($form, $form_state); }