WIP: Implement profile validation

This commit is contained in:
Björn Fromme
2023-09-19 16:32:14 +02:00
parent dc364cf320
commit 9a95daa3db
7 changed files with 90 additions and 17 deletions
@@ -17,10 +17,12 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Validator\Validator\ValidatorInterface;
class ProfileController extends AbstractController
{
public function __construct(
private readonly ValidatorInterface $validator,
private readonly EntityManagerInterface $entityManager,
private readonly ApiClient $apiClient,
private readonly UploadHandler $uploadHandler,
@@ -48,6 +50,9 @@ class ProfileController extends AbstractController
$this->updatePhoto($user, $uploadSession);
}
// Validate teamer data to show missing data right away
$errors = $this->validator->validate($teamer);
$form = $this->createForm(TeamerProfileType::class, $teamer, ['upload_session' => $uploadSession]);
$form->handleRequest($request);
@@ -72,6 +77,7 @@ class ProfileController extends AbstractController
return $this->render('teamer/profile.html.twig', [
'form' => $form->createView(),
'teamer' => $teamer,
'errors' => $errors,
]);
}