Tag

Forms

5 posts tagged Forms.

Posts

  • Diagram: individually labeled form_row fields inside a form_start/form_end frame, with a form_rest chip carrying the CSRF token at the bottom.

    09/02/2026

    Rendering a Symfony form field by field in Twig

    One call renders the whole form and gives you no say in the markup. Splitting it up is four functions, and the one that matters most is form_rest - the safety net that stops a forgotten field from silently disappearing.

  • Diagram: addError() called from a controller landing on a specific field's inline error and on the form's own top-level error banner.

    06/11/2015

    Adding a form error from a controller in Symfony

    Some checks cannot live in a constraint because they need something the form does not know about. FormError attaches the message to a field, or to the form itself, so it renders where the user is looking.

  • Diagram: attribute(form, 'field_' ~ i) building a dynamic field name, resolving down to field_1 and field_2, guarded by an is defined check.

    04/14/2015

    Dynamic field names in Twig with attribute() and ~

    Dot notation cannot reach a property whose name you are building in the template. attribute() takes the name as a string, the tilde concatenates it, and `is defined` keeps the loop from throwing on a gap.

  • Diagram: MM and YYYY select fields feeding a DataTransformer that outputs a DateTime, beside a struck-through DateType with a hidden day control.

    11/19/2014

    A card expiry month/year field in Symfony

    The old answer was to render DateType's day dropdown and hide it with CSS. That works until somebody uses a screen reader. Two choice fields and a small transformer do the job honestly.

  • Diagram: a DataTransformer throwing an exception into a field that shows a generic message, beside an alternative field showing custom text built from the invalid value.

    08/20/2014

    invalid_message: what a failed transformer shows

    A transformer that cannot convert what was typed throws, and Symfony turns that into a message the user reads. Left alone it says nothing useful; invalid_message is where you replace it.

Often tagged together with