Skip to content

The page

phil/contact-form-bundle

ContactFormController shows the form, and once a message is valid and sent, redirects to the same page with ?sent=1 — 303 See Other — so that reloading sends nothing twice.

ResponseWhen
200The page, or the page after a message left (sent is true)
303The message left
422A field is missing or wrong, or the protection held the submission
503The mail transport refused the message: the form stays filled and asks to try again; the refusal is logged, never the message

The form

ContactFormType, to a ContactMessage:

FieldChecked
namerequired, 100 characters at most
emailrequired, an address by RFC 5322 without warnings, as Symfony Mime writes it in Reply-To, 254 characters at most
subjectoptional, 150 characters at most
messagerequired, 10 to 5000 characters

It carries phil/spam-protection-bundle's protection, scope contact_form, its subject and message read by the content rules: a held submission gets the protection's one error, which never says why.

The templates

@PhilContactForm/contact.html.twig is a page of its own. An application gives its own with the key template, extending its layout and including the form:

{% extends 'base.html.twig' %}
{% block body %}
    <h1>{{ 'contact_form.title'|trans({}, 'phil_contact_form') }}</h1>
    {% include '@PhilContactForm/_form.html.twig' %}
{% endblock %}

_form.html.twig says when the message left or failed, and renders the form. Labels are in the phil_contact_form translation domain.