Symfony & Twig: Simple month and year form selection widget

This is a very useful Twig that I use in a lot of different forms.  I attach a listener and when they click "Update" it will redirect the user by appending the URL with the /year/month to hook nice and cleanly in built-in routes to pass the year and month into different controllers.  

Symfony Twig: Accessing global values reference

Here is a reference list to access global values within Twig: For more Symfony Twig shortcuts, view the Twig Cheatsheet with recent updates added, a perfect reference for Symfony web developers.

Extending a Symfony parent Twig block in child view’s block with parent() call easy, useful and DRY

Twig blocks are like methods in a class.  If the Twig container is a class, Twig blocks are methods.  So you can call on a parent Twig view and extend the parent just like a function using the "parent()" function like below within the dynamic content tags, which are a pair of squiggly brackets.  Here's…

Accessing Symfony global and server variables in Twig views through the “app” variable

In Symfony, you don't always have to actually pass values from your controllers to your Twig views.  Twig can actually pull global and server values directly through the super global "app" variable.  Most frequently, you can access these corresponding objects like Kernel, Request, Security and Session variables like so: Need more Twig tips?  View…

Symfony Twig view conditionally shows current username of user logged in

Here is a quick way to access the user object from the Symfony user or the FOSUserBundle.  In this Twig example below is a conditional statement that if the user is authenticated and has a role, it will display "Hi Aaron Belchamber" or whatever the user's name is.