Skip to content

Commit

Permalink
Fix coding standards for generate:form command. (#3900)
Browse files Browse the repository at this point in the history
  • Loading branch information
kporras07 authored and LOBsTerr committed Apr 6, 2019
1 parent ee8ebb5 commit 22490f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Generator/FormGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions templates/module/routing-form.yml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@
{% else %}
requirements:
_access: 'TRUE'
{% endif %}
{% endif %}

{% endif %}
9 changes: 8 additions & 1 deletion templates/module/src/Form/form.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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 %}

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 22490f2

Please sign in to comment.