Add contact form with reCAPTCHA, saved to DB, viewable in admin
Adds a public /contact page (name/email/message, protected by the same reCAPTCHA v3 setup used on registration) that persists submissions to a new contact_message table, plus a Contact section in the admin panel to read them. Linked from the site footer.
This commit is contained in:
@@ -136,6 +136,7 @@
|
||||
{ route: 'game_admin_games', label: 'Games', icon: '🎮' },
|
||||
{ route: 'game_admin_sessions', label: 'Sessions', icon: '▶' },
|
||||
{ route: 'game_admin_feedback', label: 'Feedback', icon: '💬' },
|
||||
{ route: 'game_admin_contact', label: 'Contact', icon: '📨' },
|
||||
{ route: 'game_admin_email_log', label: 'Email Log', icon: '✉' },
|
||||
] %}
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
{% extends 'game/admin/base.html.twig' %}
|
||||
|
||||
{% block title %}Contact Messages — Admin{% endblock %}
|
||||
|
||||
{% block admin_body %}
|
||||
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem;">
|
||||
<h1 style="margin: 0; font-size: 1.5rem; color: #0f172a;">Contact Messages</h1>
|
||||
<span style="color: #64748b; font-size: 0.9rem;">{{ messages|length }} message{{ messages|length != 1 ? 's' : '' }}</span>
|
||||
</div>
|
||||
|
||||
<div style="background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.07); overflow: hidden;">
|
||||
<table class="admin-datatable" style="width: 100%; min-width: 760px; border-collapse: collapse; font-size: 0.9rem;">
|
||||
<thead>
|
||||
<tr style="background: #f1f5f9; border-bottom: 1px solid #e2e8f0;">
|
||||
<th style="padding: 0.75rem 1rem; text-align: left; color: #475569; font-weight: 600;">Received</th>
|
||||
<th style="padding: 0.75rem 1rem; text-align: left; color: #475569; font-weight: 600;">Name</th>
|
||||
<th style="padding: 0.75rem 1rem; text-align: left; color: #475569; font-weight: 600;">Email</th>
|
||||
<th style="padding: 0.75rem 1rem; text-align: left; color: #475569; font-weight: 600;">Message</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for entry in messages %}
|
||||
<tr style="border-bottom: 1px solid #f1f5f9;">
|
||||
<td style="padding: 0.75rem 1rem; color: #475569; white-space: nowrap;">{{ entry.createdAt|date('Y-m-d H:i:s') }}</td>
|
||||
<td style="padding: 0.75rem 1rem; font-weight: 500; color: #0f172a;">{{ entry.name }}</td>
|
||||
<td style="padding: 0.75rem 1rem; color: #475569;">
|
||||
<a href="mailto:{{ entry.email }}" style="color: #3b82f6; text-decoration: none;">{{ entry.email }}</a>
|
||||
</td>
|
||||
<td style="padding: 0.75rem 1rem; color: #475569; max-width: 480px; white-space: pre-wrap;">{{ entry.message }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="4" style="padding: 2rem; text-align: center; color: #94a3b8;">No messages yet.</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user