Last active
December 7, 2018 18:23
-
-
Save tatma/52c9e7bbec4026c332e0757b7b6568f9 to your computer and use it in GitHub Desktop.
Gestione del form nel controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Controller; | |
use Symfony\Component\Routing\Annotation\Route; | |
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
use Symfony\Component\HttpFoundation\Request; | |
use App\Form\ArticleType; | |
use App\Entity\Article; | |
class ArticleController extends Controller | |
{ | |
/** | |
* @Route("/create-new", name="article_new") | |
*/ | |
public function newArticle(Request $request) | |
{ | |
$article = new Article(); | |
$form = $this->createForm(ArticleType::class, $article); | |
$form->handleRequest($request); | |
if ($form->isSubmitted() && $form->isValid()) { | |
// Il form è stato sottomesso | |
} | |
return $this->render('Backend/new.html.twig', [ | |
'form' => $form->createView() | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment