app/views/shared/partials/_content_blocks_form.html.erb
<% fields ||= ["header", "title", "intro", "body", "media_contents"] %>
<% list_of_content_blocks = record.content_blocks.presence || [OpenStruct.new] %>
<div id="nested-content-blocks">
<% list_of_content_blocks.each_with_index do |content_block, index| %>
<%= form.fields_for "content_blocks[#{index}]", content_block do |fcb| %>
<div class="nested-content-block-form">
<div class="card mb-4">
<% if fields.include?("header") %>
<div class="d-flex flex-wrap justify-content-between card-header py-3 bg-dark text-white">
<h4>
Bereich
</h4>
<%= link_to "#", class: "removeContent btn btn-sm btn-danger" do %>
<i class="fa fa-trash text-white"></i>
<% end %>
</div>
<% end %>
<div class="card-body">
<% if fields.include?("media_contents") %>
<h3 class="mb-3 font-weight-bold d-sm-flex align-items-center justify-content-between">
Dateien
</h3>
<p>
Sie können jedem Bereich eine oder mehrere Dateien hinzufügen. Mehrere Bilder in einem
Bereich werden als Slider/Karussell dargestellt.
</p>
<%= render(
partial: "shared/partials/media_contents_form",
locals: {
record: content_block,
form: fcb,
form_class: "nested-media-content-block"
}
) %>
<hr />
<% end %>
<div class="row">
<div class="col">
<% if fields.include?("title") %>
<div class="form-group">
<label for="description">Überschrift</label>
<%= fcb.text_field :title, class: "form-control" %>
</div>
<% end %>
<% if fields.include?("intro") %>
<div class="form-group">
<label for="description">Einleitung</label>
<%= fcb.text_area :intro, class: "form-control html-editor", rows: 5 %>
<p class="hint">Dieser Text wird hervorgehoben dargestellt.</p>
</div>
<% end %>
<% if fields.include?("body") %>
<div class="form-group">
<label for="description">Text</label>
<%= fcb.text_area :body, class: "form-control html-editor html-editor-text", rows: 10 %>
</div>
<% end %>
</div>
</div>
</div>
</div>
</div>
<% end %>
<% end %>
</div>