| 1 | {% extends "base.html" %} |
| 2 | |
| 3 | {% block content %} |
| 4 | <div hx-target="#form-messages" hx-swap="innerHTML"> |
| 5 | |
| 6 | <div id="form-messages"></div> |
| 7 | |
| 8 | <form hx-post="{% url 'contact_submit' %}" |
| 9 | hx-vars="csrfToken:'{{ csrf_token }}'" |
| 10 | hx-request='{"timeout": 15000}' |
| 11 | hx-disabled-elt="#submit-btn" |
| 12 | hx-on:htmx:afterSwap="clearForm(this)" |
| 13 | hx-on::configRequest="addTimezone(event)"> |
| 14 | |
| 15 | <div class="field"> |
| 16 | <label for="name">Name</label> |
| 17 | <input type="text" name="name" id="name" required> |
| 18 | </div> |
| 19 | |
| 20 | <div class="field"> |
| 21 | <label for="email">Email</label> |
| 22 | <input type="email" name="email" id="email" required> |
| 23 | </div> |
| 24 | |
| 25 | <div class="field"> |
| 26 | <label for="message">Message</label> |
| 27 | <textarea name="message" id="message" required |
| 28 | hx-on:htmx:validation:validate="customValidate(this)"></textarea> |
| 29 | </div> |
| 30 | |
| 31 | {% if show_department %} |
| 32 | <div class="field"> |
| 33 | <select name="department" |
| 34 | hx-get="{% url 'department_contacts' %}" |
| 35 | hx-target="#contact-person" |
| 36 | hx-indicator="#dept-spinner" |
| 37 | hx-params="department"> |
| 38 | <option value="">Select department...</option> |
| 39 | {% for dept in departments %} |
| 40 | <option value="{{ dept.id }}">{{ dept.name }}</option> |
| 41 | {% endfor %} |
| 42 | </select> |
| 43 | <img id="dept-spinner" class="htmx-indicator" src="{% static 'spinner.gif' %}"> |
| 44 | <div id="contact-person"></div> |
| 45 | </div> |
| 46 | {% endif %} |
| 47 | |
| 48 | <button type="submit" id="submit-btn">Send Message</button> |
| 49 | </form> |
| 50 | </div> |
| 51 | {% endblock %} |