2015-03-14 15:46
浏览 39


I am trying to create simple page to display content of the table (customer: id, first_name, last_name) with Symfony + doctrine. I created GS\OrderBundle\Entity\Customer with columns and getters/setters. Created route for it. I want to create a view , something like:

        {% for c in form %}
        {% set id = c.get('value') %}
            <td>{{ form_widget(c) }}</td>
            <td>{{ c[id].firstName }}</td>
            <td>{{ c[id].lastName }}</td>
    {% endfor %}

and Controller to pass the values from the customer table to this view. I am trying something like:

namespace GS\OrderBundle\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use GS\OrderBundle\Entity\Customer;
use Doctrine\ORM\EntityManager;

class CustomerListController extends Controller
    public function listAction()

        $repository = $this->getDoctrine()
        $customer = $repository->findAll();

        $form = $this->createFormBuilder($customer)->getForm();

        return $this->render(
            array('form' => $form->createView())

        return new Response($names);

On the symfony website I found only examples with setting data or outputing single row data. Could you please provide any simple example how to display content of the table in the view?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题