Reformat
This commit is contained in:
@@ -32,7 +32,6 @@ class PostController extends AbstractController
|
||||
$form = $this->createForm(PostType::class, $post);
|
||||
|
||||
$form->handleRequest($request);
|
||||
//dd($form);
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$post = $form->getData();
|
||||
$post->setPublicationDate(new \DateTimeImmutable("now"));
|
||||
@@ -44,25 +43,25 @@ class PostController extends AbstractController
|
||||
}
|
||||
|
||||
return $this->render('post/post.html.twig', [
|
||||
'form' => $form, //->createView(),
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/posts/edit/{id}', name: 'app_edit_post')]
|
||||
#[IsGranted('ROLE_USER', message: 'You must be logged in to access this page.')]
|
||||
public function edit(Request $request, EntityManagerInterface $entityManager, Post $post): Response
|
||||
{
|
||||
$form = $this->createForm(PostType::class, $post);
|
||||
$form->handleRequest($request);
|
||||
{
|
||||
$form = $this->createForm(PostType::class, $post);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->flush();
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_posts');
|
||||
return $this->redirectToRoute('app_posts');
|
||||
}
|
||||
|
||||
return $this->render('post/edit.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->render('post/edit.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@@ -5,10 +5,10 @@ namespace App\Controller;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use App\Entity\Species;
|
||||
use App\Form\SpeciesType;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class SpeciesController extends AbstractController
|
||||
|
Reference in New Issue
Block a user