Hi,
I have a $id that needs to put inside the field userid of article table by using this function of PHP Symfony.
I really appreciate if someone can help me to fix my function.
Thanks,
public function submitAction($id)
{
print_r('UserID to enter is ');
print_r($id);
$message='';
$article = new Article();
$form = $this->container->get('form.factory')->create(new ArticleForm(), $article);
$request = $this->container->get('request');
if ($request->getMethod() == 'POST')
{
$form->bindRequest($request);
if ($form->isValid())
{
$em = $this->container->get('doctrine')->getEntityManager();
$em->persist($article);
$em->flush();
$message='Article successfully added!';
}
}
return $this->container->get('templating')->renderResponse('AcmeWebAppBundle:Article:submit.html.twig', array('form' => $form->createView(),'message' => $message,'userID' => $id));
}
I have a $id that needs to put inside the field userid of article table by using this function of PHP Symfony.
I really appreciate if someone can help me to fix my function.
Thanks,
public function submitAction($id)
{
print_r('UserID to enter is ');
print_r($id);
$message='';
$article = new Article();
$form = $this->container->get('form.factory')->create(new ArticleForm(), $article);
$request = $this->container->get('request');
if ($request->getMethod() == 'POST')
{
$form->bindRequest($request);
if ($form->isValid())
{
$em = $this->container->get('doctrine')->getEntityManager();
$em->persist($article);
$em->flush();
$message='Article successfully added!';
}
}
return $this->container->get('templating')->renderResponse('AcmeWebAppBundle:Article:submit.html.twig', array('form' => $form->createView(),'message' => $message,'userID' => $id));
}