News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Dean Clatworthy:
Theming/styling error messages in Symfony 2
August 30, 2012 @ 11:40:40

For the Symfony2 users out there, Dean Clatworthy has a handy tip to help you customize the output of your application a bit more - a method for styling the error messages coming from forms using a custom template.

I spent a large portion of my day today trying to customize the HTML produced by Symfony 2 for form errors. The documentation has a section on how to do this, but for the life of me, I could not make it work. Here is a working, re-usable solution.

His solution involves the creation of a template in your "/Resources/views/Form/" directory that contains a Twig template for the error set output. This is then applied in your view using an additional parameter on the error output tag, including this new template from the "Form" directory. This sort of styling could also be applied if you needed custom elements with their own layouts in your forms as well.

0 comments voice your opinion now!
symfony2 error message theme style twig template tutorial


blog comments powered by Disqus

Similar Posts

Digett.com: How to Theme the Comment Form in Drupal 6

Lars Strojny's Blog: Dependency Injection Container Refactorings, Part Two

NETTUTS.com: Building a Better BlogRoll: Dynamic Fun with SimplePie and jQuery

HowToForge.com: Installing PHP5 Debugger On OpenSUSE 11.3

Zend Developer Zone: Using the Plurk API with PHP


Community Events

Don't see your event here?
Let us know!


language api conference podcast interview symfony2 application community laravel configure framework part2 install example series introduction opinion php7 release performance

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework