agenda-libre-ruby/app/views/events/_form.html.haml

77 lines
2.2 KiB
Plaintext

= form_for @event, url: (@moderation ? moderation_path(@moderation) : @event.persisted? ? event_path(@event) : nil) do |f|
- if @event.errors.any?
#error_explanation.error.flash
%h2= "#{pluralize(@event.errors.count, "error")} prohibited this event from being saved:"
- @event.errors.full_messages.each do |msg|
%p= msg
- if @event.persisted?
- unless @moderation
= hidden_field_tag :secret, params[:secret]
.field.title
.helper
:markdown
#{t '.title_helper'}
= f.label :title
= f.text_field :title, required: true, size: 70
.field.start_time
= f.label :start_time
= f.datetime_local_field :start_time, required: true
.field.end_time
= f.label :end_time
= f.datetime_local_field :end_time, required: true
.field
.helper
:markdown
#{t '.description_helper'}
= f.label :description
= f.text_area :description, rows: 25, cols: 90
.field
= f.label :address
= f.text_field :address, size: 70
.field
= f.label :city
= f.text_field :city, required: true, size: 70, list: :cities
%datalist#cities
- City.connection.select_values('select distinct name from cities join events on name=city group by city order by count(*) desc').each do |name|
%option= name
.field
= f.label :region
= f.select :region,
options_from_collection_for_select(Region.all, 'id', 'name', @event.region)
.field
= f.label :locality
= f.select :locality,
options_for_select([[t('attributes.locality_0'), 0], [t('attributes.locality_1'), 1]], @event.locality)
.field
.helper
:markdown
#{t '.url_helper'}
= f.label :url
= f.url_field :url, required: true, size: 70, placeholder: 'Ex: http://april.org'
.field
.helper
:markdown
#{t '.contact_helper'}
= f.label :contact
= f.email_field :contact, required: true, size: 70
.field
.helper
:markdown
#{t '.submitter_helper'}
= f.label :submitter
= f.email_field :submitter, size: 70
.field
.helper
:markdown
#{t '.tags_helper'}
= f.label :tags
= f.text_field :tags, size: 70
.actions
= f.submit t('.visualise'), formaction: :preview
= f.submit t('.save')