app/views/shared/partials/_price_informations_form.html.erb
<% fields = ["description", "amount"] %>
<% list_of_price_informations = record.price_informations.presence || [OpenStruct.new] %>
<div class="row">
<div class="col">
<h3 class="d-sm-flex align-items-center justify-content-between my-4">
Preise
</h3>
</div>
</div>
<div id="nested-price_informations">
<% list_of_price_informations.each_with_index do |price, index| %>
<%= fields_for "#{record_type}[price_informations][#{index}]", price do |fp| %>
<div class="nested-price_information-form<%= " d-none" if empty?(price, fields) %>">
<div class="card mb-4">
<div class="d-flex flex-wrap justify-content-between card-header py-3 bg-dark text-white">
<h4>
Preiskategorie
</h4>
<%= link_to "#", class: "remove btn btn-sm btn-danger" do %>
<i class="fa fa-trash text-white"></i>
<% end %>
</div>
<div class="card-body">
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label for="description">Beschreibung</label>
<%= fp.text_field :description, class: "form-control" %>
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label for="description">Preis</label>
<%= fp.text_field :amount, class: "form-control" %>
</div>
</div>
</div>
</div>
</div>
</div>
<% end %>
<% end %>
</div>
<%= link_to "#", class: "btn btn-sm btn-secondary", id: "nested-add-price_information" do %>
<i class="fas fa-plus text-white mr-2"></i>
Preiskategorie hinzufügen
<% end %>
<hr />