= form_for @changeset, @action, [multipart: true], fn f ->
  = if @changeset.action do
    .alert.alert-danger
      p Oops, something went wrong! Please check the errors below.

  = if @changeset.data.__meta__.state != :loaded do
    .field
      => label f, :image, "Upload image:"
      = file_input f, :image, class: "input input--wide"
      = error_tag f, :image
      = error_tag f, :image_mime_type
      = error_tag f, :image_size
      = error_tag f, :image_width
      = error_tag f, :image_height
  - else
    .field
      = link "Change image", to: ~p"/admin/adverts/#{@changeset.data}/image/edit", class: "button"

  .field
    => label f, :link, "Link which the advert should take users to:"
    = url_input f, :link, class: "input input--wide", placeholder: "Link", required: true
    = error_tag f, :link

  .field
    => label f, :title, "Title/alt-text for the advert:"
    = text_input f, :title, class: "input input--wide", placeholder: "Title", required: true
    = error_tag f, :title

  .field
    => label f, :start_date, "Start time for the advert (usually \"now\"):"
    = text_input f, :start_date, class: "input input--wide", placeholder: "Start"
    = error_tag f, :start_date

  .field
    => label f, :finish_date, "Finish time for the advert (e.g. \"2 weeks from now\"):"
    = text_input f, :finish_date, class: "input input--wide", placeholder: "Finish"
    = error_tag f, :finish_date

  .field
    => label f, :notes, "Notes (Payment details, contact info, etc):"
    = text_input f, :notes, class: "input input--wide", placeholder: "Notes"
    = error_tag f, :notes

  .field
    => label f, :restrictions, "Restriction:"
    = select f, :restrictions, restrictions(), class: "input"
    = error_tag f, :restrictions

  .field
    => checkbox f, :live, class: "checkbox"
    = label f, :live, "Live"

  = submit "Save Advert", class: "button"
