<% lookup_keys = overridable_lookup_keys(puppetclass, obj) %>
<% lookup_keys.each_with_index do |lookup_key, index| %>
  <% lookup_value = lookup_value(obj, lookup_key) %>
    <%
       # LookupValue#match is generated automatically by Host#lookup_values_attributes=
       # from the name, so don't present errors directly to the user.  Any validation
       # errors should also be visible against the Host#name field.
       if lookup_value.errors[:match].any?
         logger.debug("Ignoring #{lookup_value.inspect} match errors: #{lookup_value.errors[:match]}")
         lookup_value.errors.delete(:match)
       end
    %>
  <% overridden = lookup_key.overridden?(obj) %>
  <% error = lookup_value.errors %>
  <tr id="puppetclass_<%= puppetclass.id %>_params[<%= lookup_key.id %>]"
    class="fields <%= 'overridden' if overridden %>">
    <%= content_tag(:td, puppetclass.name, :rowspan => lookup_keys.size, :class => "ellipsis") if index == 0 %>
    <td class="ellipsis param_name">
      <%= lookup_key.key %>
    </td>
    <td <%= "class=has-error" if error.present? %>>
      <div class="input-group">
        <%= lookup_key_with_diagnostic(obj, lookup_key, lookup_value) %>
        <span class="input-group-btn">
          <%= hidden_toggle(lookup_key.hidden_value?, 'font', 'font', true) %>
          <%= fullscreen_button("$(this).parent().prev()") %>
          <%= override_toggle(overridden) %>
        </span>
      </div>
      <%= content_tag(:span, error.full_messages.to_sentence, :class => "help-block") if error.present? %>
    </td>
    <td class="ca">
      <%= use_puppet_default_check_box(lookup_key, lookup_value, !overridden) %>
      <%= hidden_lookup_value_fields(lookup_key, lookup_value, !overridden) %>
    </td>
  </tr>
<% end %>
