<%= simple_form_for @event do |f| %>
  <%= f.error_notification %>
  <%= f.input :title %>
  <%= f.input :description %>
  <div id="epiceditor"></div>
  <%= f.association :category, include_blank: true, collection: Category.order(:title).map { |c| [c.title, c.id, {'data-color' => c.color}] } %>
  <%= f.input :location %>
  <%= f.association :users, label_method: :username, collection: User.approved %>
  <%= f.input :all_day %>
  <%= f.input :starts_at, {minute_step: 15, default: params[:start] ? Time.at(params[:start].to_i) : Time.now, start_year: Date.today.year} %>
  <%= f.input :ends_at, {minute_step: 15, default: (params[:start] ? Time.at(params[:start].to_i) : Time.now) + 2.hours, start_year: Date.today.year} %>
  <%= f.input :recurring_type, collection: [:weekly, :monthly, :yearly] %>
  <%= f.input :recurring_until, as: :date, include_blank: true, default: nil, start_year: Date.today.year %>
  <%= f.input :schedule_exceptions, as: :check_boxes, label_method: proc{ |d| l d, format: '%d.%m.%Y' }, collection: @event.schedule_exceptions unless @event.schedule_exceptions.empty? %>
  <%= f.button :submit %>
<% end %>

<%= simple_form_for @event do |f| %>
  <%= f.error_notification %>
  <%= f.input :title %>
  <%= f.input :description %>
  <div id="epiceditor"></div>
  <%= f.association :category, include_blank: true, collection: Category.order(:title).map { |c| [c.title, c.id, {'data-color' => c.color}] } %>
  <%= f.input :location %>
  <%= f.association :users, label_method: :username, collection: User.approved %>
  <%= f.input :all_day %>
  <%= f.input :starts_at, {minute_step: 15, default: params[:start] ? Time.at(params[:start].to_i) : Time.now} %>
  <%= f.input :ends_at, {minute_step: 15, default: (params[:start] ? Time.at(params[:start].to_i) : Time.now) + 2.hours} %>
  <%= f.input :recurring_type, collection: [:weekly, :monthly, :yearly] %>
  <%= f.input :recurring_until, as: :date, include_blank: true, default: nil, start_year: Date.today.year %>
  <%= f.input :schedule_exceptions, as: :check_boxes, label_method: proc{ |d| l d, format: '%d.%m.%Y' }, collection: @event.schedule_exceptions unless @event.schedule_exceptions.empty? %>
  <%= f.button :submit %>
<% end %>

Allow year of event to be before current year (important when editing old events with schedule)
Allow year of event to be before current year (important when editing old events with schedule)
