{% extends "layout.html" %}
{% from "_macros.html" import render_event_place_form_script, render_manage_form_styles, render_manage_form_scripts, render_jquery_steps_header, render_cropper_block, render_crop_image_form_section, render_google_place_autocomplete_header, render_google_place_autocomplete_field, render_field_with_errors, render_field %}

{%- block title -%}
{{ _('Update place') }}
{%- endblock -%}

{% block styles %}
{{ render_manage_form_styles() }}
{% endblock %}

{% block header %}
{{ render_manage_form_scripts() }}
{{ render_jquery_steps_header() }}
{{ render_google_place_autocomplete_header() }}
{{ render_event_place_form_script(current_admin_unit, place) }}
{{ render_cropper_block() }}
{% endblock %}

{% block content %}

<h1>{{ _('Update place') }}</h1>
<form id="main-form" action="" method="POST" enctype="multipart/form-data">
  {{ form.hidden_tag() }}

  <div class="my-5">
    {{ render_google_place_autocomplete_field() }}
  </div>

  <div class="card mb-4">
    <div class="card-header">
      {{ _('Place') }}
    </div>
    <div class="card-body">
      {{ render_field_with_errors(form.name, role="presentation", autocomplete="off") }}
    </div>
  </div>

  <div class="card mb-4">
    <div class="card-header">
      {{ _('Location') }}
    </div>
    <div class="card-body">
      {{ form.location.hidden_tag() }}
      {{ render_field_with_errors(form.location.street) }}
      {{ render_field_with_errors(form.location.postalCode) }}
      {{ render_field_with_errors(form.location.city) }}
      {{ render_field_with_errors(form.location.state) }}
      {{ render_field_with_errors(form.location.latitude) }}
      {{ render_field_with_errors(form.location.longitude) }}
    </div>
  </div>

  {{ render_crop_image_form_section(form.photo) }}

  <div class="card mb-4">
    <div class="card-header">
      {{ _('Additional information') }}
    </div>
    <div class="card-body">
    {{ render_field_with_errors(form.url) }}
    {{ render_field_with_errors(form.description) }}
    </div>
  </div>

  {{ render_field(form.submit) }}
</form>

{% endblock %}
