<%= form_with(model: subproject) do |form| %> <% if subproject.errors.any? %>

<%= pluralize(subproject.errors.count, "error") %> prohibited this subproject from being saved:

<% end %> <% subproject_form_fields.each do |attrib| %>
<%= form.label attrib, style: "display: block" %> <% case attrib %> <% when :project %> <%= form.collection_select :project_id, Project.all, :id, -> (project) { "#{project.name}" }, prompt: "Select Project" %> <% when :client, :owner, :builder %> <%= form.collection_select "#{attrib}_id", Client.all, :id, -> (client) { "#{client.company_name} (#{client.lastname}, #{client.firstname})" }, prompt: "Select #{attrib.capitalize}" %> <% else %> <%= form.text_field attrib, value: subproject.send(attrib) %> <% end %>
<% end %>
<%= form.submit %>
<% end %>