As with Symfony 2.1 (it can work for 2.0, but not sure) to apply the theme to the collection, you do this:
Let's say we have a set of products (we have several Product objects)
Controller:
$repository = $this->getDoctrine()->getRepository('ExampleBundle:Product'); $products = $repository->findAll(); $productCollection = new Products; foreach ($products as $product) { $productCollection->getProducts()->add($product); } $collection = $this->createForm(new ProductsType, $productCollection); return $this->render('ExampleBundle:Default:index.html.twig', array( 'collection' => $collection->createView() ));
Your topic may look like this:
{% block _productsType_products_entry_name_row %} <div class="yourDivName">{{ block('form_widget') }}</div> {% endblock %} {% block _productsType_products_entry_description_row %} <div class="yourDivDescription">{{ block('form_widget') }}</div> {% endblock %}
The โinputโ trick, where the branch will complete the task, to apply the above changes to each row and for each field that you specify
Hope this helps!
source share