symfony crud simple request

48 views Asked by At

i'm trying to do a simple add without the form generated by doctrine

$mail = new Subscription();
$request = $this->getRequest();
if ($request->getMethod() == "POST") {

    $em = $this->getDoctrine()->getManager();
    $samplees = $request->get("samplees");

    $mail->setEmail($samplees);

    $em->persist($mail);
    $em->flush();

    return $this->redirect($this->generateUrl('user_homepage'));
}
1

There are 1 answers

1
DonCallisto On

First of all, Doctrine2 will not handle any form facility (nor creation neither data binding process): the whole process is up to symfony and its form bundle.

That said, if you need to retrieve a posted data you need to modify

$samplees = $request->get("samplees");

into

$samplees = $request->request->get("samplees");

This because $request is the whole Request object (so, basically, it will handle also get parameters [$request->query->get(...)] just to say one of the functionalities)