32 lines
1.0 KiB
Plaintext
32 lines
1.0 KiB
Plaintext
<%= form_with(model: subproject) do |form| %>
|
|
<% if subproject.errors.any? %>
|
|
<div style="color: red">
|
|
<h2><%= pluralize(subproject.errors.count, "error") %> prohibited this subproject from being saved:</h2>
|
|
|
|
<ul>
|
|
<% subproject.errors.each do |error| %>
|
|
<li><%= error.full_message %></li>
|
|
<% end %>
|
|
</ul>
|
|
</div>
|
|
<% end %>
|
|
|
|
<% subproject_form_fields.each do |attrib| %>
|
|
<div>
|
|
<%= 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 %>
|
|
</div>
|
|
<% end %>
|
|
|
|
<div>
|
|
<%= form.submit %>
|
|
</div>
|
|
<% end %>
|