|
|
@ -32,7 +32,6 @@ class PostController extends AbstractController
|
|
|
|
$form = $this->createForm(PostType::class, $post);
|
|
|
|
$form = $this->createForm(PostType::class, $post);
|
|
|
|
|
|
|
|
|
|
|
|
$form->handleRequest($request);
|
|
|
|
$form->handleRequest($request);
|
|
|
|
//dd($form);
|
|
|
|
|
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
|
|
$post = $form->getData();
|
|
|
|
$post = $form->getData();
|
|
|
|
$post->setPublicationDate(new \DateTimeImmutable("now"));
|
|
|
|
$post->setPublicationDate(new \DateTimeImmutable("now"));
|
|
|
@ -44,25 +43,25 @@ class PostController extends AbstractController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $this->render('post/post.html.twig', [
|
|
|
|
return $this->render('post/post.html.twig', [
|
|
|
|
'form' => $form, //->createView(),
|
|
|
|
'form' => $form,
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[Route('/posts/edit/{id}', name: 'app_edit_post')]
|
|
|
|
#[Route('/posts/edit/{id}', name: 'app_edit_post')]
|
|
|
|
#[IsGranted('ROLE_USER', message: 'You must be logged in to access this page.')]
|
|
|
|
#[IsGranted('ROLE_USER', message: 'You must be logged in to access this page.')]
|
|
|
|
public function edit(Request $request, EntityManagerInterface $entityManager, Post $post): Response
|
|
|
|
public function edit(Request $request, EntityManagerInterface $entityManager, Post $post): Response
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$form = $this->createForm(PostType::class, $post);
|
|
|
|
$form = $this->createForm(PostType::class, $post);
|
|
|
|
$form->handleRequest($request);
|
|
|
|
$form->handleRequest($request);
|
|
|
|
|
|
|
|
|
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
|
|
$entityManager->flush();
|
|
|
|
$entityManager->flush();
|
|
|
|
|
|
|
|
|
|
|
|
return $this->redirectToRoute('app_posts');
|
|
|
|
return $this->redirectToRoute('app_posts');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $this->render('post/edit.html.twig', [
|
|
|
|
return $this->render('post/edit.html.twig', [
|
|
|
|
'form' => $form->createView(),
|
|
|
|
'form' => $form->createView(),
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|