[英]Symfony2 “Parameter ”“ for route ”“ must match ”[^/]++“ (”“ given) to generate a corresponding URL.”
I have this routes file: 我有这个路线文件:
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
Now when I want to proceed to the indexRechercheZones
route, an error occured : 现在,当我想继续使用
indexRechercheZones
路由时,发生错误 :
An exception has been thrown during the rendering of a template ("Parameter "nom" for route "modifierZones" must match "[^/]++" ("" given) to generate a corresponding URL.") in MySpaceGestion...sBundle:...:indexZonesTechniques.html.twig at line 71.
在渲染模板期间抛出异常(“参数”nom“for route”modifierZones“必须匹配”[^ /] ++“(”“给定)以生成相应的URL。”)在MySpaceGestion中... sBundle:...:第71行的indexZonesTechniques.html.twig。
In my twig line 71, I have this code : 在我的树枝线71中,我有这个代码 :
<a href="{{ path('modifierZones', {'nom': zonetechnique.nom}) }}"><button class="btn btn-warning btn-xs">Modifier</button></a>
I think that is a regex problem, a problem with the url writing rule for symfony, but I don't how I can fix this error. 我认为这是一个正则表达式问题,symfony的url编写规则存在问题,但我不知道如何修复此错误。 I have tried some thing like adding this line in my route:
我尝试过在我的路线中添加这一行的一些事情:
indexRechercheZones:
path: /gestionzonestechniques/
defaults: { _controller: MySpaceGestionEquipementsTechniquesBundle:GestionZonesTechniques:indexZonesTechnique }
requirements:
nom: \d+
methods: GET
or like this at the requirements: 或者像这样要求:
requirements:
nom: '[a-zA-Z0-9-_\/-\s.^]+'
But it does not match. 但它不匹配。 Someone could help?
有人可以帮忙吗?
Thank you... 谢谢...
Like @Coussinsky said, some values
for your field
"nom" are empty on your database. 就像@Coussinsky所说,你的
field
“nom”的某些values
在你的数据库中是空的。
You could make this parameter to null
if you want, or just change the empty values on your database. 如果需要,可以将此参数设置为
null
,或者只更改数据库中的空值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.