<%= form_for(record) do |f| %>

  <fieldset>
    <h3 class="fieldset-heading"><%= header_text %></h3>

    <div class="row">
      <% names.each do |name| %>
        <% unless name.nil? %>
          <div class="col-md-4">
            <div class="form-group">
              <%= f.label model_class.fields[name].display_name, model_class.fields[name].display_name, class: 'control-label' %><br />
              <%= model_class.fields[name].generate_field f, record[record.size - 1] %>
            </div>
          </div>
        <% end %>
      <% end %>
    </div>

    <%= f.fields_for fields_for_class.to_s.parameterize.to_sym do |fields_for_fields| %>
    <div class="row">
      <% fields_for_names.each do |name| %>
        <% unless name.nil? %>
          <div class="col-md-4">
            <div class="form-group">
              <%= fields_for_fields.label fields_for_class.fields[name].display_name, fields_for_class.fields[name].display_name, class: 'control-label' %><br />
              <%= fields_for_class.fields[name].generate_field fields_for_fields, record[record.size - 1] %>
            </div>
          </div>
        <% end %>
      <% end %>
    </div>
    <% end %>
    <%= f.submit update_text, class: 'btn btn-primary' %>
  </fieldset>

<% end %>
