pomm-project / pomm-bundle

Pomm2 bundle for Symfony
81 stars 31 forks source link

Twig and relation #69

Closed hayusama closed 7 years ago

hayusama commented 7 years ago

Hi,

For a project i use your bundle. It's perfect for generate entity with a existing database. But i have a noob question ahah:

In my controller $catalogues = $this->get('pomm')['my_db1'] ->getModel('\AppBundle\Entity\MyDb1\PublicSchema\CatalogueModel') ->findAll() ; return $this->render('SiteBundle:Default:homePage.html.twig',array('catalogues'=>$catalogues));

But in my view (twig) How to access the variable ?? {% for catalogue in catalogues %} {{dump(catalogue)}} --> value inside {% endfor %}

Result dump `Catalogue {#1132 ▼

container: array:13 [▼

"ID" => 8
"Code" => "MATIÈRE PREMIÈRE"
"Actif" => true
"DateAjout" => DateTime {#1212 ▶}
"Index" => 0
"PriseCommande" => false
"Description" => ""
"Couleur" => "Green"
"CouleurText" => "#000000"
"Tarif" => null
"WebActif" => false
"WebTitre" => null
"WebDescription" => null

] -status: 1 }`

catalogue.ID (not working) catalogue.container.ID (not working)

Other question : If my entity relation : in catalogue, WebActif --> relation with other table How to access Webactif because the dump returns only an ID, do I have to create my own method?

Sorry for my english.... -_-

chanmix51 commented 7 years ago

Hey hayusama.

Thank you for posting. I suggest you use stack-overflow (use the tag pomm) for this kind of requests so github would remain a reference for Pomm’s tickets, and people having the same problem as you will easily find the answer. Thank you.

hayusama commented 7 years ago

Hi Gregoire,

Thanks you for your reply. My topic http://stackoverflow.com/questions/43348538/pomm-twig-and-relation