Hello,
Still struggling with symfony. I’m trying to reproduce the example given at http://symfony.com/doc/current/forms.html (a very simple form without doctrine involved) and I’m getting the message “Class AppBundle\Controller\Request does not exist” (though it does in /vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Request.php).
There may be somewhere a path that is missing. Here’s the code of lmy controller :
<?php
// src/AppBundle/Controller/TaskClassController.php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use AppBundle\Entity\TaskClass;
class TasksFormController extends Controller
{
public function tasksFormAction(Request $request)
{
$task = new TaskClass();
$form = $this->createFormBuilder($task)
->add('task', TextType::class)
->add('dueDate', DateType::class)
->add('save', SubmitType::class, array('label' => 'Create Task'))
->getForm();
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid())
{
$task = $form->getData();
return $this->redirectToRoute('TaskCreated', array('task' => $task,));
}
return $this->render('tasksForm.html.twig', array('form' => $form->createView(),));
}
}
?>
Thanks in advance,
MC