notebook/app/views/content/form/_relation_input.html.erb
2016-09-29 15:58:30 +02:00

22 lines
856 B
Plaintext

<%# Usage: render 'content/form/relation_input', f: f, attribute: attribute, relation: through_class %>
<div class="hoverable" style="padding: 8px">
<div>
<%= f.label attribute, attribute.humanize.capitalize %>
</div>
<div id="<%= relation %>">
<%= f.fields_for relation do |builder| %>
<%= render 'content/form/groupship_fields', f: builder, attribute: attribute.singularize, parent: f.object %>
<% end %>
<div class="links">
<% color = f.object.send(attribute).build.class.color %>
<%= link_to_add_association "add #{attribute.to_s.singularize.humanize}", f, relation,
class: "btn #{color}",
partial: 'content/form/groupship_fields',
render_options: { locals: {
attribute: attribute.singularize,
parent: f.object
}} %>
</div>
</div>
</div>