app/views/events/_form.html.erb
<%= form_for @event, html: { class: 'form-horizontal event' } do |f| %>
<%= render partial: 'application/validation_errors', locals: {model: @event} %>
<div class="form-group order-1">
<h3 class="form-group__title"><%= t('activerecord.attributes.event.basic_information') %></h3>
</div>
<div class="form-group order-1">
<%= f.label :name, class: 'control-label col-lg-2' %>
<div class="col-lg-10">
<%= f.text_field :name, class: 'form-control' %>
<%= f.error_span(:name) %>
</div>
</div>
<div class="form-group order-1 row">
<%= f.label :image, t('activerecord.models.image.one'), class: 'control-label col-lg-2'%>
<div class="col-lg-10">
<% unless @event.new_record? %>
<%= image_tag @event.image_url || image_path('missing_event_image.jpg'), id: 'preview', style: 'max-width:100px; max-height:100px'%>
<% end %>
<%= f.file_field :image, class: 'form-control-file' %>
<% if @event.image %>
<%= f.check_box :remove_image %>
<%= f.label :remove_image, t('helpers.submit.delete', model: t('activerecord.models.image.one'))+ " " %>
<% end %>
</div>
</div>
<div class="form-group order-1">
<%= f.label :description, class: 'control-label col-lg-2' %>
<div class="col-lg-10">
<%= f.text_area :description, class: 'form-control' %>
</div>
</div>
<div class="form-group order-3">
<%= f.label :max_teams, class: 'control-label col-lg-2' %>
<div class="col-lg-10">
<%= f.number_field :max_teams, class: 'form-control' %>
<%= f.error_span(:max_teams) %>
</div>
</div>
<div class="form-group order-1">
<%= f.label :discipline, class: 'control-label col-lg-2' %>
<div class="col-lg-10">
<%= f.text_field :discipline, list: "discipline", class: 'form-control' %>
<datalist id = "discipline">
<option value=<%= t('events.discipline.basketball') %>>
<option value=<%= t('events.discipline.soccer')%>>
<option value=<%= t('events.discipline.tennis')%>>
<option value=<%= t('events.discipline.table_tennis')%>>
<option value=<%= t('events.discipline.table_football')%>>
<option value=<%= t('events.discipline.volleyball')%>>
</datalist>
<%= f.error_span(:discipline) %>
</div>
</div>
<%# Rendering the correct template depending on the event type %>
<%= render "events/forms/#{@event.model_name}", form: f %>
<div class="form-group order-7">
<div class="col-lg-offset-2 col-lg-10">
<%= f.submit nil,
class: 'btn btn-primary' %>
<%= link_to t('helpers.links.cancel'),
back_path,
class: 'btn btn-default' %>
</div>
</div>
<% end %>