user2632918
user2632918

Reputation:

how to view result of doctrine result

I am using Symfony and in my Controller i have the following function:

/**
 * @Route("/place/{id}", name="place")
 */
public function placeAction( $id )
{
    $em = $this->getDoctrine()->getManager();

    $place = $em->getRepository( "RoAllgemeinBundle:Place" )->find($id);
    return $this->render( "RoAllgemeinBundle:Default:place.html.twig",
        array(
            "place"=>$place
        ));
}

In my twig i wanna view the matched place

<h1>{{ description }}</h1>

In the database I have a result for my given idnumber. but when i try to view the page in the browser i got a exception from symfony

Variable "description" does not exist in RowocoAllgemeinBundle:Default:place.html.twig at line 3

But i have a column with name description..

this in the Entity-Class:

/**
 * @var string
 */
private $description;

/**
 * Set description
 *
 * @param string $description
 * @return Place
 */
public function setDescription($description)
{
    $this->description = $description;

    return $this;
}

/**
 * Get description
 *
 * @return string 
 */
public function getDescription()
{
    return $this->description;
}

Did i forgott something?

Upvotes: 1

Views: 47

Answers (1)

voodoo417
voodoo417

Reputation: 12101

Change to:

<h1>{{ place.description }}</h1>

Upvotes: 1

Related Questions