symfony:关于路由和 url_for() 的问题 [英] symfony: question about routes and url_for()
问题描述
我有这条路线:
category_set_representative_image:
url: /categoria-settare-immaggine-rappresentativa
param: { module: category_new, action: setRepresentativeImage }
class: sfDoctrineRoute
options: { model: Category, type: object }
以及与此相关的链接:
url_for('category_set_representative_image', array('sf_subject' => $category))
当我点击链接时:
sfError404Exception:操作categoriasettareimmagginerappresentativa/index"才不是存在.
sfError404Exception: Action "categoriasettareimmagginerappresentativa/index" does not exist.
有什么想法吗?
EDIT 在 Flask 的回答之后:
EDIT after the answer of Flask:
这是我的代码,如果我从 javascript 标签中调用相同的 url_for()
没有问题.
This is my code, no problems if I call the same url_for()
out of javascript tags.
<script>
$.post('<?php echo url_for('category_set_representative_image', array('sf_subject' => $category)) ?>',
function(){
alert("fadsf");
}
);
</script>
SF 1.4
贾维
推荐答案
对于路由,您必须在路由前添加@":url_for('@category_set_representative_image', array('sf_subject' => $类别))
for routes you will have to add "@" before the route: url_for('@category_set_representative_image', array('sf_subject' => $category))
你有routing.yml结尾的默认路由吗?
do you have you the default route at the end of the routing.yml?
这篇关于symfony:关于路由和 url_for() 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!