Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
Symfony3 Impossible to access an attribute ("small_pizza") on a string variable ("Margherita")

I trying to display price, but occurs error Impossible to access an attribute ("small_pizza") on a string variable ("Margherita").

This is my Controller:

/**
     * @Route(
     *      "/menu",
     *      name = "pizza_menu"
     * )
     * 
     * @Template
     */
    public function menuAction() {

        $Repo = $this->getDoctrine()->getRepository('PizzaBundle:Menu');
        $rows = $Repo->findAll();

        return array(
            'rows' => $rows
        );
    }

And this is my database: enter image description here

In a Twig code is this:

{% for entry in rows %}
   <tr>
      <td>{{ entry.id }}</td>
      <td>{{ entry.name }}</td>
      <td>{{ entry.components }}</td>
      <td>
          <ul>
              <li>{{ entry.name.small_pizza }}</li>
              <li>{{ entry.name.small_pizza }}</li>
              <li>{{ entry.name.small_pizza }}</li>
              <li>{{ entry.name.small_pizza }}</li>

          </ul>
      </td>
  </tr>

Help me please :)

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Try accessing to the prince entity navigating the relations so try this:

<li>{{ entry.price.small_pizza }}</li>

instead of

<li>{{ entry.name.small_pizza }}</li>

Hope this help

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!