In your services.yml file, you define a template for your action
app.admin.product: class: AppBundle\Admin\ProductAdmin arguments: [~, AppBundle\Entity\Product, AppBundle:Admin\Product] tags: - {name: sonata.admin, manager_type: orm, group: Products, label: Products} calls: - [ setTemplate, [edit, AppBundle:Product:edit.html.twig]]
In this template, you can override templates for fields in your form:
{% extends 'SonataAdminBundle:CRUD:base_edit.html.twig' %} {% form_theme form.selectall 'AppBundle:Form:selectall.html.twig' %} {% form_theme form.Country 'AppBundle:Form:country.html.twig' %}
Then my template looks like this:
{% block form_row %} <div class="form-group"> {{ form_label(form) }} {% set c = 0 %} {% for i in form %} {% set c = c+1 %} {% if (c == 1) %} <div style="float: left; width: 20%;"> {% endif%} {{ form_row(i) }} {% if ((c == 60) or (form|length == loop.index)) %} </div> {% set c = 0 %} {% endif%} {% endfor %} </div> {% endblock form_row %}
In this case, the flags of my countries are displayed in a column of 60 elements, and not in the same column with the entire list of elements.
Hope this helps someone else.
Mortisqc
source share