Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix coding standards for generate:form command. #3900

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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