tirenweb
tirenweb

Reputation: 31749

symfony: about passing parameters with url_for()

I have this line in a template:

<a href="<?php echo url_for('category_set_representative_image', array('aux' => 4, 'sf_subject' => $category)) ?>">jander</a>

So as you can guess when I click that link, it executes an action. Inside that action I have this:

var_dump($request->getParameter('aux'));var_dump($request->getParameter('sf_subject'));die("fasf");

It's printing 4 and NULL. Why NULL? I expected the $category object was showed..

Upvotes: 0

Views: 4082

Answers (2)

Grad van Horck
Grad van Horck

Reputation: 4506

You can't get the sf_subject parameter that way. You can only use the sf_subject with the sfDoctrineRoute or sfPropelRoute. In your code, you can then get the selected object with $this->getRoute()->getObject().

Upvotes: 2

What is the html representation of your first line?

Seems like in your template $category is not defined, so the < a > should looks like

foo.php?aux=4&sf_subject=null or
foo.php?aux=4

Define the category in your template :-)

Upvotes: 0

Related Questions