Optimized register form

This commit is contained in:
Kevin Frantz
2018-09-06 17:47:47 +02:00
parent 56fb409477
commit d9fc547f85
5 changed files with 19 additions and 23 deletions

View File

@@ -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()]);
}
}