Routing exception in symfony (“The ”/league/:id_league/members/new“ route has some missing mandatory parameters (:id_league)”)

China☆狼群 提交于 2019-12-13 18:05:48

问题


Hi everyone and sorry for my bad english,

I have a problem with the routing: in the members page to a league ("/league/ID_LEAGUE/members"), the link for the action "new" becomes "/league/members/news" (the league's id disappears). I would like to keep that ID and create a url like "/league/ID_LEAGUE/members/ new" so you can select in selectbox the current league...

I'm trying to do this as follows

members:
    class: sfDoctrineRouteCollection
    options: { model: Members, module: members, column: id_member, with_wildcard_routes: true }

# List to league (id)'s members
memebers_league:
    url: /league/:id/members
    options: { model: Members, type: list }
    param: { module: members, action: index }

# New member
members_new:
    url: /league/:id_league/members/new
    class: sfDoctrineRoute
    options: { model: Members, type: object }
    param:   { module: members, action: new }

With these routes I get this exception "The "/league/:id_league/members/new" route has some missing mandatory parameters (:id_league)" (in "Members.class.php" there is the getter "getIdLeague() ).

someone could help me?

thanks in advance


回答1:


Add a default value :

param:   { module: members, action: new, id_league: 0}


来源:https://stackoverflow.com/questions/8861723/routing-exception-in-symfony-the-league-id-league-members-new-route-has-so

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