-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
203 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace VSV\GVQ_API\Account\Forms; | ||
|
||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\EmailType; | ||
use Symfony\Component\Form\Extension\Core\Type\PasswordType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
use Symfony\Component\Translation\TranslatorInterface; | ||
use Symfony\Component\Validator\Constraints\Email; | ||
use Symfony\Component\Validator\Constraints\NotBlank; | ||
|
||
class LoginFormType extends AbstractType | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function buildForm(FormBuilderInterface $builder, array $options) | ||
{ | ||
/** @var TranslatorInterface $translator */ | ||
$translator = $options['translator']; | ||
|
||
$builder | ||
->add( | ||
'email', | ||
EmailType::class, | ||
[ | ||
'constraints' => [ | ||
new NotBlank( | ||
[ | ||
'message' => $translator->trans('Empty field'), | ||
] | ||
), | ||
new Email( | ||
[ | ||
'message' => $translator->trans('Invalid email pattern'), | ||
] | ||
), | ||
], | ||
] | ||
) | ||
->add( | ||
'password', | ||
PasswordType::class, | ||
[ | ||
'constraints' => [ | ||
new NotBlank( | ||
[ | ||
'message' => $translator->trans('Empty field'), | ||
] | ||
), | ||
], | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver->setDefaults( | ||
[ | ||
'translator' => null, | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{% extends 'base.html.twig' %} | ||
|
||
{% block title %}{% trans %}Inloggen{% endtrans %}{% endblock %} | ||
|
||
{% block content %} | ||
<div class="card"> | ||
<div class="card-header"> | ||
<div class="card-title">{% trans %}Inloggen{% endtrans %}</div> | ||
</div> | ||
|
||
<div class="card-body"> | ||
{{ form_start(form, {'attr': {'novalidate': 'novalidate'}}) }} | ||
<div class="form-group"> | ||
<label for="form_email">{% trans %}E-mail{% endtrans %}</label> | ||
{{ form_widget(form.email) }} | ||
{{ form_errors(form.email) }} | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="form_password">{% trans %}Wachtwoord{% endtrans %}</label> | ||
{{ form_widget(form.password) }} | ||
{{ form_errors(form.password) }} | ||
</div> | ||
|
||
<div class="form-group"> | ||
<button type="submit" class="btn btn-primary">{% trans %}Inloggen{% endtrans %}</button> | ||
</div> | ||
{{ form_end(form) }} | ||
</div> | ||
|
||
<div class="card-footer"> | ||
<div class="card-link"><a href="#">{% trans %}Wachtwoord vergeten{% endtrans %}</a></div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace VSV\GVQ_API\Account\Forms; | ||
|
||
use VSV\GVQ_API\Common\Forms\ExtensionsAwareTypeTestCase; | ||
|
||
class LoginFormTypeTest extends ExtensionsAwareTypeTestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_can_be_created(): void | ||
{ | ||
$form = $this->factory->create( | ||
LoginFormType::class, | ||
null, | ||
[ | ||
'translator' => $this->translator, | ||
] | ||
); | ||
|
||
$form->submit([]); | ||
|
||
$this->assertTrue($form->isSynchronized()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters