<% fields_for_header_container2(layout_builder).each do |index, field| %>
  <% if field["table"] == @current_table %>
    <% @current_row = @row %>
  <% else %>
    <% @current_row = get_related_row(@current_table, field["table"], @row["id"]) %>
  <% end %>

  <% if field["editable"] == "true" %>
    <div class="row editable-row m-b">
      <div class="col-xs-12">
        <div class="editable-content-wrapper">
          <b><%= field["title"] %></b>:

          <% if current_row_valid?(@current_row, field) %>
            <span class="editable-content header-container2-content" onclick="showEditable(event);">
              <%= @current_row[field["title"]] %>
            </span>
          <% else %>
            <span class="editable-content header-container2-content" onclick="showEditable(event);">
              --
            </span>
          <% end %>
        </div>

        <%= render partial: 'tables/layout/editable_input', locals: { field: field } %>
      </div>
    </div>
  <% else %>
    <div class="m-b">
      <b><%= field["title"] %></b>:

      <% if @current_row &&  !@current_row[field["title"]].blank? %>
        <span class="header-container2-content">
          <%= @current_row[field["title"]] %>
        </span>
      <% else %>
        <span class="header-container2-content">
          --
        </span>
      <% end %>
    </div>
  <% end %>
<% end  %>
