app/views/offers/_form.html.erb
<%= fields_for :offer, offer do |f| %>
<%= hidden_field_tag "offer[id]", f.object.id if f.object.id.present? %>
<%= hidden_field_tag "offer[generic_type]", @offer.generic_type %>
<div class="row">
<div class="col">
<div class="form-group">
<label for="description">Anzeigen-Titel *</label>
<%= f.text_field :title, required: true, class: "form-control" %>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group">
<label for="description">Externe ID</label>
<%= f.text_field :external_id, class: "form-control" %>
</div>
</div>
</div>
<% list_of_content_blocks = offer.content_blocks.presence || [OpenStruct.new] %>
<div class="row">
<div class="col">
<div class="form-group">
<label for="description">Inhalt</label>
<% list_of_content_blocks.each_with_index do |content_block, index| %>
<%= f.fields_for "content_blocks[#{index}]", content_block do |fcb| %>
<%= fcb.text_area :body, class: "form-control html-editor html-editor-text", rows: 10 %>
<% end %>
<% end %>
</div>
</div>
</div>
<hr />
<div class="row">
<div class="col">
<h3 class="d-sm-flex align-items-center justify-content-between my-4">
Dateien
</h3>
</div>
</div>
<%= render partial: "shared/partials/media_contents_form", locals: { record: offer, form: f } %>
<hr />
<div class="row">
<div class="col-12 col-sm-6">
<div class="form-group">
<label for="description">Veröffentlichungsdatum *</label>
<%= f.date_field(
:publication_date,
required: true,
class: "form-control",
value: f.object.publication_date.try(:to_date) || Time.now.to_date
) %>
</div>
</div>
</div>
<%= render(
partial: "shared/partials/dates_form",
locals: {
record: offer,
form: f,
fields: ["date_end"],
requireds: ["date_end"],
labels: {
date_end: "Ablaufdatum"
},
values: {
date_end: (Time.now + 4.weeks).to_date
},
force_visibility: true
}) %>
<hr />
<div class="row">
<div class="col">
<h3 class="d-sm-flex align-items-center justify-content-between my-4">
Firma
</h3>
</div>
</div>
<%= render partial: "shared/partials/operating_company_form", locals: { record: offer, form: f, object: offer.companies.try(:first) } %>
<hr />
<div class="row justify-content-center pb-4">
<%= f.submit "Speichern", class: "btn btn-primary btn--big" %>
</div>
<% end %>