Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass variable $id into userid(field) of article table.

Status
Not open for further replies.

pheng56

IS-IT--Management
Feb 24, 2013
7
CA
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));
}
 
first, always post code within [ignore]
Code:
[/ignore] tags.

print_r is only used for arrays and objects. use echo for strings and numbers.

you are using the $id correctly from a php standpoint.

are you looking for help with php or symphony? if php then please provide the errors that you are getting so that we can help.

if you are looking for help with symphony I strongly suggest that you will get a better response by asking in a symphony forum.
 
Hi,

Can you advise me where is Symfony forum in tek-tips ?

Thanks again,
 
to my knowledge there is no symfony forum in tek-tips. feel free to set one up yourself. you can request this through the contact-us link at the bottom of the page.

however I believe that there are a number of active forums on the internet. you may be better asking there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top