mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Optimized register form
This commit is contained in:
parent
56fb409477
commit
d9fc547f85
@ -2,3 +2,4 @@ twig:
|
||||
paths: ['%kernel.project_dir%/templates']
|
||||
debug: '%kernel.debug%'
|
||||
strict_variables: '%kernel.debug%'
|
||||
form_themes: ['bootstrap_4_layout.html.twig']
|
||||
|
@ -5,6 +5,10 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
use App\Entity\User;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -29,6 +33,12 @@ class UserController extends AbstractController implements UserControllerInterfa
|
||||
*/
|
||||
public function register(): Response
|
||||
{
|
||||
return $this->render("user/register.html.twig");
|
||||
$user = new User();
|
||||
$form = $this->createFormBuilder($user)
|
||||
->add('username', TextType::class)
|
||||
->add('password', PasswordType::class)
|
||||
->add('save', SubmitType::class,['label' => 'register'])
|
||||
->getForm();
|
||||
return $this->render("user/register.html.twig",['form'=>$form->createView()]);
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ trait PasswordAttribut {
|
||||
*/
|
||||
protected $password;
|
||||
|
||||
public function getPassword():string
|
||||
public function getPassword():?string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ trait UsernameAttribut{
|
||||
*/
|
||||
protected $username;
|
||||
|
||||
public function getUsername():string
|
||||
public function getUsername():?string
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
@ -1,25 +1,10 @@
|
||||
{% extends "frames/default.html.twig" %}
|
||||
{% block title %}
|
||||
register
|
||||
{% trans %}register{% endtrans %}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<h1>Register</h1>
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label for="email">Email address</label> <input type="email"
|
||||
class="form-control" id="email" aria-describedby="emailHelp"
|
||||
name="email" placeholder="Enter email">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="name">Username</label> <input type="email"
|
||||
class="form-control" id="name" aria-describedby="emailHelp"
|
||||
name="name" placeholder="Enter Username">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label> <input type="password"
|
||||
class="form-control" id="password" name="password"
|
||||
placeholder="Password">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
<h1>{% trans %}register{% endtrans %}</h1>
|
||||
{{ form_start(form) }}
|
||||
{{ form_widget(form) }}
|
||||
{{ form_end(form) }}
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user