Tag

Forms

5 posts tagged Forms.

  • Rendering a Symfony form field by field in Twig

    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.

  • Adding a form error from a controller in Symfony

    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.

  • Dynamic field names in Twig with attribute() and ~

    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.

  • A card expiry month/year field in Symfony

    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.

  • invalid_message: what a failed transformer shows

    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