app/views/tours/_form.html.erb
<%= fields_for :tour, tour do |f| %>
<%= hidden_field_tag "tour[id]", f.object.id if f.object.id.present? %>
<div class="row">
<div class="col">
<h2 class="d-sm-flex align-items-center justify-content-between my-4">
Kategorien
</h2>
<p>
Jede Tour kann in einer oder mehreren Kategorien abgelegt werden.
<p>
<%= render partial: "shared/partials/categories_form", locals: { record: tour, record_type: "tour", form: f, tag_filter: "tour" } %>
<%= link_to "#", class: "btn btn-sm btn-secondary", id: "nested-add-category" do %>
<i class="fas fa-plus text-white mr-2"></i>
Kategorie hinzufügen
<% end %>
</div>
</div>
<hr />
<div class="row">
<div class="col">
<div class="form-group">
<label for="description">Name *</label>
<%= f.text_field :name, required: true, class: "form-control" %>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group">
<label for="description">Beschreibung</label>
<%= f.text_area :description, class: "form-control html-editor" %>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group">
<label for="description">Länge der Strecke</label>
<%= f.number_field :length_km, class: "form-control" %>
</div>
</div>
</div>
<%= render partial: "tours/form_partials/tour_path", locals: { record: tour } %>
<%= render partial: "tours/form_partials/tour_stop_form", locals: { record: tour, form: f } %>
<div class="row">
<div class="col">
<h3 class="d-sm-flex align-items-center justify-content-between my-4">
Adresse
</h3>
</div>
</div>
<% address = tour.try(:addresses).try(:first) || OpenStruct.new(geo_location: nil) %>
<%= f.fields_for :addresses, address do |fadd| %>
<%= render partial: "shared/partials/address_form", locals: { form: fadd, address: address } %>
<% end %>
<hr />
<div class="row">
<div class="col">
<h3 class="d-sm-flex align-items-center justify-content-between my-4">
Betreiber
</h3>
</div>
</div>
<%= render partial: "shared/partials/operating_company_form", locals: { record: tour, form: f } %>
<hr />
<div class="row">
<div class="col">
<h3 class="d-sm-flex align-items-center justify-content-between my-4">
Kontakt
</h3>
</div>
</div>
<% contact = tour.try(:contact) || OpenStruct.new(web_urls: [OpenStruct.new]) %>
<%= f.fields_for "contact", contact do |fc| %>
<%= render partial: "shared/partials/contact_form", locals: { form: fc, contact: contact } %>
<% end %>
<%= render partial: "shared/partials/web_url_form", locals: { record: tour, record_type: "tour", form: f } %>
<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: tour, form: f } %>
<hr />
<div class="row justify-content-center pb-4">
<%= f.submit "Speichern", class: "btn btn-primary btn--big" %>
</div>
<% end %>