symfony: question about routes and url_for()

巧了我就是萌 提交于 2019-12-12 05:48:17

问题


I have this route:

category_set_representative_image:
  url:     /categoria-settare-immaggine-rappresentativa
  param:   { module: category_new, action: setRepresentativeImage }
  class:   sfDoctrineRoute
  options: { model: Category, type: object }

and a link associated to this:

url_for('category_set_representative_image', array('sf_subject' => $category))

When I click the link I get:

sfError404Exception: Action "categoriasettareimmagginerappresentativa/index" does not exist.

Any idea?

EDIT after the answer of Flask:

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

Javi


回答1:


for routes you will have to add "@" before the route: url_for('@category_set_representative_image', array('sf_subject' => $category))

do you have you the default route at the end of the routing.yml?




回答2:


Currently it isn't executing the rule above.

You probably have a more generic routing rule before this rule. (the default /:module/:action rule?)



来源:https://stackoverflow.com/questions/6995530/symfony-question-about-routes-and-url-for

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!