Search code examples
csstwigsymfonystylingformbuilder

Symfony from styling time widgets


I am currently trying to style a form that is generated by symfony form builder.

there is a bootstrap overlay on it but i want to move the time widgets so they align next to each other.

form view

twig template rows formbuilder


Solution

  • You can display each input of your form independently using

    form_row(form.yourinputname)

    form_row is the combination of the field's label, errors and widget.

    You can see the doc about this

    EDIT:

    So if you want to display some widgets in one line you can do this (you have to use a loop to display each input of your form collection) :

    <style type="text/css">
        .myClass{
           .inline{
             display: inline-block;
           }
        }
    </style>
    
    <div class='myClass'>
      {% for business in form.businesshours %}
          <div class="inline">{{ form_row(business.day) }}</div>
          <div class="inline">{{ form_row(business.openTime) }}</div>
          <div class="inline">{{ form_row(business.breakStart) }}</div>
          <div class="inline">{{ form_row(business.breakEnd) }}</div>
          <div class="inline">{{ form_row(business.closeTime) }}</div>
      {% endfor %}
    </div>