add dropdowns for client, owner, builder in subproject form
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
module SubprojectsHelper
|
||||
def subproject_form_fields
|
||||
[:subproject_name, :project_id, :client_id, :owner_id, :builder_id]
|
||||
[:subproject_name, :project, :client, :owner, :builder]
|
||||
end
|
||||
|
||||
def subproject_view_fields
|
||||
|
||||
@@ -14,7 +14,14 @@
|
||||
<% subproject_form_fields.each do |attrib| %>
|
||||
<div>
|
||||
<%= form.label attrib, style: "display: block" %>
|
||||
<%= form.text_field attrib, value: subproject.send(attrib) %>
|
||||
<% 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 %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user