Symfony Tokenized URLs not working

Looking through the Symfony documentation, I found a way to secure a form with a "token" field. I'm trying to implement that and the form generates a token but it doesn't pass it in the URL to the "showSuccess.php" page so it's now displaying my _admin.php partial.

I thought it had to do with the routing but I have the routing the same as they do and it still doesn't work.

car:
  class: sfDoctrineRouteCollection
  options: { model: car, column: token }
  requirements: { token: \w+ }

car_show:
  url: /car/:iditem.:sf_format
  class: sfDoctrineRoute
  options: { model: car, type: object }
  param: { module: car, action: show, sf_format: html }
  requirements: { iditem: \d+, sf_method: get }

Now the form itself requires the token field in the URL, but when I submit the form it's supposed to pass a "tokenized URL" to the success page so that a partial can be displayed, but the URL defaults to the "iditem" field instead of the "token" field so my partial doesn't render.

I found that if I change the name of the second route to something else (or delete it), then the tokenized URLs work. But then the regular URL doesn't.

Is this something I need to change in the class files?

Here is my reference. Symfony Documentation

Answers


I actually figured it out. The "sfDoctrineCollection" for the first set of routes was creating a "car_show" route so the one that I put in there was overwriting it. All I did was change the name of the second route to something different and it worked.

car:
  class: sfDoctrineRouteCollection
  options: { model: car, column: token }
  requirements: { token: \w+ }

car_show_id:
  url: /car/:iditem.:sf_format
  class: sfDoctrineRoute
  options: { model: car, type: object }
  param: { module: car, action: show, sf_format: html }
  requirements: { iditem: \d+, sf_method: get }

I just had to update all references to the old route in all of my links.


Need Your Help

What's the difference between a System property and environment variable

java environment-variables classpath system system-properties

I am not clear about this. When I run a java App or run an Applet in applet viewer, (in the IDE environment), System.getProperty("java.class.path") gives me the same as System.getenv("CLASSPATH") ...

Extract all numbers from a text file and store them in another file

regex bash sed awk

I have a text file which have lots of lines. I want to extract all the numbers from that file.