<%= form.select :subject_manifest, subject_manifests.map { |m| [
I18n.t("activerecord.models.#{m.model_class_name.underscore}.other"),
m.name
] }, { include_blank: true }, class: "constraint-subject-selector" %>
<% models = manifest.model_class_name.constantize.where(organization: current_organization) %>
<%= fields_for "constraints[#{index}][subject_model][#{manifest.name}]", constraint do |subject_fields| %>
<%= subject_fields.hidden_field :subject_manifest, value: manifest.name.to_s %>
<%= subject_fields.select :subject_id, models.map { |m| [translated_attribute(m.title), m.id] }, { selected: selected_space, include_blank: true }, class: "constraint-subject-model-selector" %>
<% models.each do |model| %>
<%= fields_for "constraints[#{index}][subject_model][#{manifest.name}][component_model][#{model.id}]", constraint do |component_fields| %>
<%= component_fields.hidden_field :subject_id, value: model.id %>
<% if model.respond_to?(:components) %>
<%= component_fields.select :component_id, model.components.map { |c| [translated_attribute(c.name), c.id] }, selected: selected_component, include_blank: true %>
<% else %>
<%= component_fields.hidden_field :component_id, value: nil %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<%= form.hidden_field :id %>
<%= form.hidden_field :deleted %>