Dragos Holban

Symfony2: How to Get the Label for a Specific Form Field in Twig

If you need to render the label value for a specific field without rendering the entire HTML label element (e. g. to use it for a placeholder), you can do it by using the label form variable: [crayon-5f2a12a281667667439569/]


Symfony2: How to Check If a Form Field Has Errors in Twig

Sometimes you need to check if a field or even the entire form has errors before rendering them (e.g. when adding an errors container). Here's the code snippet that allows you to check for the errors form variable: [crayon-5f2a12a281bfc425099530/]