[Answered ]-How to move form field to new line with bootstrap grid?

1👍

Nice and easy, just use col-md-6 as you already have for field 1 and field 2, but for field 3 use col-md-6 and col-md-offset-6.

So it needs to be as follows:

<div class="col-md-6"></div><div class="col-md-6"></div>
<div class="col-md-6 col-md-offset-6"></div>
<div class="col-md-6"></div><div class="col-md-6"></div>
<div class="col-md-6 col-md-offset-6"></div>

Use CSS to change the offset direction:

.col-md-offset-6 {
      margin-right: 50% !important;
}
👤Alex

1👍

Couldn’t you move your if condition to be above your application of the col-md-6? I’m not familiar with django’s syntax, but something like:

{% for field in form %}
  {% if field.name == 'field3' %}
      {% bootstrap_field field form_group_class='col-md-12 form-group label-floating' %}
  {% else %}
    {% bootstrap_field field form_group_class='col-md-6 form-group label-floating' %}  
  {% endif %}
{% endfor %}
👤Capo

Leave a comment