notebook/app/views/content/form/_relation_input.html.erb
2016-10-24 23:05:40 +02:00

29 lines
1.1 KiB
Plaintext

<%# Usage: render 'content/form/relation_input', f: f, attribute: attribute, relation: through_class %>
<div class="content-field">
<div class="hoverable" style="padding: 8px; margin-bottom: 1rem;">
<div>
<%= f.label attribute, I18n.translate(
"attributes.#{f.object.class.name.downcase}.#{attribute}",
scope: :activerecord,
default: 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>
</div>