Home > Symfony > Prevent Symfony from ‘formatting’ request parameters

Prevent Symfony from ‘formatting’ request parameters

September 15th, 2009 admin Leave a comment Go to comments

I’ve been using Symfony for 2 years and I always though their formatting of routes was really cool. For example, if you want to generate a link to a specific action, you’d do something like this:

<?php
echo link_to('Name of Link', '@route_to_action?param1=value1&param2=value2');

And it would generate something like this:

<a href="/module/action/param1/value1/param2/value2">Name of Link</a>

However, for the first time, I found myself NOT wanting this behavior. I wanted:

<a href="/module/action?param1=value1&param2=value2">Name of Link</a>

I looked high and low, on and off for a few days. I finally found something in the forums, with a note saying it should be in the documentation, but isn’t.

<?php
echo link_to('Name of Link', '@route_to_action', array('query_string' => 'param1=value1&param2=value2');
64670 be
Categories: Symfony Tags:
  1. No comments yet.
  1. No trackbacks yet.