magnetico-web/src/Controller/MainController.php
2018-06-25 04:02:27 +03:00

30 lines
827 B
PHP

<?php
namespace App\Controller;
use App\Form\LoginType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Response;
class MainController extends Controller
{
public function index(): Response
{
return $this->render('index.html.twig', [
'loginForm' => $this->createLoginForm('')->createView(),
]);
}
private function createLoginForm(string $username): FormInterface
{
$form = $this->createForm(LoginType::class, null, [
'action' => $this->generateUrl('user_login'),
]);
$form->get('_username')->setData($username);
$form->add('submit', SubmitType::class);
return $form;
}
}