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.
<form id="yearMonthWidget" name="newDate1" method="get" action=""> <select name="month"> {% for mo in 1..12 %} <option value="{{ mo }}">{{ ('2012-' ~mo~'-01')|date("M") }}</option> {% endfor %} </select> <select name="year"> {% for yr in "now"|date("Y")+1..2010 %} <option value="{{ yr }}">{{ yr }}</option> {% endfor %} </select> <input type="submit" value="Update"/> </form>