2014-12-22 75 views
0

我在使用symfony的項目中工作,並且我有一個視圖,在該視圖中我要顯示一個實體的圖像,我使用了與上載相同的方法通過文檔建議報告,上傳工作正常,但我所面臨的問題,當我想要顯示的圖像,我得到一個異常如下:無法在使用樹枝的視圖中顯示上傳的圖像(symfony2)

A hash key must be followed by a colon (:). Unexpected token "punctuation" of value "." ("punctuation" expected with value ":") in StockStockBundle:Payantfournisseur:imprime.html.twig at line 135 

有,讓我這個異常的代碼: 在控制器端:

$em = $this->getDoctrine()->getManager(); 

    $entity = new Payantfournisseur(); 
    $entity = $em->getRepository('StockStockBundle:Payantfournisseur')->find($id); 
    $user = $this->get('security.context')->getToken()->getUser(); 
    $societe = new \User\UserBundle\Entity\Societe(); 
    $societe = $em->getRepository('UserUserBundle:Societe')->find(2); 
    //$societe = $user->getSociete(); 
    $facture = $entity->getIdfacturefournisseur(); 
    $fournisseur = $facture->getIdfournisseur(); 
    $articles = $em->getRepository('StockStockBundle:Lignefacturefournisseur') 
         ->getArtFromLines($facture); 


    if (!$entity) { 
     throw $this->createNotFoundException('Unable to find Devis entity.'); 
    } 

    $deleteForm = $this->createDeleteForm($id); 

    return $this->render('StockStockBundle:Payantfournisseur:imprime.html.twig', array(
     'entity' => $entity, 
     'fournisseur' => $fournisseur, 
     'facture' => $facture, 
     'articles' => $articles, 
     'delete_form' => $deleteForm->createView(), 
     'societe' => $societe, 


      // 'ayoub'=>'yes ayoub', 
    )); 

在視圖方面:

<img src="{{ asset({societe.pjs.getWebPath}) }}" alt="{{ societe.pjs.alt }}" class="spaced img-responsive" /> 

給予更多的解釋,PJS與興業一個oneToOne相關的實體,PJS負責上傳的文件的實體。

如果有人有一個想法,PLZ可能是非常有幫助 在此先感謝!!!!!!!

回答

1

我發現解析錯誤樹枝

刪除括號從資產功能,使用可變喜歡這裏:

<img src="{{ asset(societe.pjs.getWebPath) }}" alt="{{ societe.pjs.alt }}" class="spaced img-responsive" /> 
+0

耶士馬安,非常感謝! – krachleur