<% errors = [] -%>
<% key_field = key_field(property) -%>

<tr class="top multi_value <%= 'template' unless set_key -%> odd" style="<%= 'display:none' unless set_key -%>">
  <% unless key_field -%>
    <%= hidden_field_tag "property_sets[#{property.key}][]", set_key -%>
  <% end -%>

  <% property.fields.each do |field| -%>
    <% if set_key -%>
      <% key = "#{property.key}.#{set_key}.#{field.key}" -%>
      <% value = Property.value(key, resource_id) -%>
      <% errors << (render "settings/error", :key => key) -%>
    <% end -%>

    <% if field == key_field -%>
      <td><%= render "settings/type_#{field.type}", :property => field, :field => field, :value => value, :name => "property_sets[#{property.key}][]", :id => "input_#{h field.key}", :size => field.indicativeSize -%></td>
    <% else -%>
      <td><%= render "settings/type_#{field.type}", :property => field, :field => field, :value => value, :name => "#{property.key}[#{field.key}][]", :id => "input_#{h field.key}", :size => field.indicativeSize -%></td>
    <% end -%>
  <% end -%>

  <td style="width: 60px;">
    <% unless hide_delete -%>
      <a href="#" class="delete link-action"><%= message('delete') -%></a>
    <% end -%>
  </td>
</tr>

<% unless errors.all?(&:blank?) -%>
  <tr>
    <% if key_field -%>
      <td></td>
    <% end -%>

    <% errors.each do |error| -%>
      <td><%= error -%></td>
    <% end -%>

    <td></td>
  </tr>
<% end -%>
