【发布时间】:2015-02-11 12:47:16
【问题描述】:
我有这个 路线 文件:
indexRechercheZones:
path: /gestionzonestechniques
defaults: { _controller: MySpaceGestionEquipementsTechniquesBundle:GestionZonesTechniques:indexZonesTechnique }
requirements:
methods: GET
modifierZones:
path: /gestionzonestechniques/modifier/{nom}
defaults: { _controller: MySpaceGestionEquipementsTechniquesBundle:GestionZonesTechniques:modifierZonesTechnique }
requirements:
methods: GET
modifierZones_process:
path: /gestionzonestechniques/modifier/process/{nom}
defaults: { _controller: MySpaceGestionEquipementsTechniquesBundle:GestionZonesTechniques:modifierZonesTechnique }
requirements:
methods: POST
现在当我想继续到indexRechercheZones路线时,发生错误:
在渲染模板期间引发了异常 ("路由 "modifierZones" 的参数 "nom" 必须匹配 "[^/]++" ("" 给定)生成相应的URL。”)在 MySpaceGestion...sBundle:...:indexZonesTechniques.html.twig 在第 71 行。
在我的树枝第 71 行,我有这个 代码:
<a href="{{ path('modifierZones', {'nom': zonetechnique.nom}) }}"><button class="btn btn-warning btn-xs">Modifier</button></a>
我认为这是一个正则表达式问题,是 symfony 的 url 写入规则的问题,但我不知道如何解决这个错误。我尝试了一些类似在我的路线中添加这一行的方法:
indexRechercheZones:
path: /gestionzonestechniques/
defaults: { _controller: MySpaceGestionEquipementsTechniquesBundle:GestionZonesTechniques:indexZonesTechnique }
requirements:
nom: \d+
methods: GET
或者像这样按要求:
requirements:
nom: '[a-zA-Z0-9-_\/-\s.^]+'
但它不匹配。有人可以帮忙吗?
谢谢...
【问题讨论】:
-
看起来你的变量
zonetechnique.nom是空的,所以你的参数nom不符合任何要求(因为你的参数不是可选的)
标签: php symfony url routes yaml