Sha256: cf9929b51e5bf762466858d0e090e4753476187ffc052d0bef26cd65c8fb06ef

Contents?: true

Size: 838 Bytes

Versions: 6

Compression:

Stored size: 838 Bytes

Contents

<%= f.label a, class: 'form-control-label label-has-one' %>

<% if f.object.send(a).blank? %>
  <% f.object.send("#{a.to_s}=", a.to_s.classify.constantize.new) %>
<% end %>

<%= f.fields_for a do |association_form| %>
  <% if f.object.id.blank? %>
    <% method = 'create_params' %>
  <% else %>
    <% method = 'update_params' %>
  <% end %>

  <% if a.is_a?(Hash) %>
    <% params_assoc = "SlashAdmin::Models::#{class_name_from_association(f.object, a).pluralize}Controller".constantize.new.send(method, from: @model_class) %>
  <% else %>
    <% params_assoc = "SlashAdmin::Models::#{a.to_s.classify.pluralize}Controller".constantize.new.send(method, from: @model_class) %>
  <% end %>

  <% params_assoc.each do |attribute| %>
    <%= render 'slash_admin/fields/form_group', f: association_form, a: attribute %>
  <% end %>
<% end %>

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
slash_admin-1.0.5 app/views/slash_admin/fields/_nested_has_one.html.erb
slash_admin-1.0.4 app/views/slash_admin/fields/_nested_has_one.html.erb
slash_admin-1.0.3 app/views/slash_admin/fields/_nested_has_one.html.erb
slash_admin-1.0.2 app/views/slash_admin/fields/_nested_has_one.html.erb
slash_admin-1.0.1 app/views/slash_admin/fields/_nested_has_one.html.erb
slash_admin-1.0 app/views/slash_admin/fields/_nested_has_one.html.erb