开发者

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..


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().


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 :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜