簡體   English   中英

Symfony2“參數”“用於路由”“必須匹配”[^ /] ++“(”“給定)以生成相應的URL。”

[英]Symfony2 “Parameter ”“ for route ”“ must match ”[^/]++“ (”“ given) to generate a corresponding URL.”

我有這個路線文件:

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路由時,發生錯誤

在渲染模板期間拋出異常(“參數”nom“for route”modifierZones“必須匹配”[^ /] ++“(”“給定)以生成相應的URL。”)在MySpaceGestion中... sBundle:...:第71行的indexZonesTechniques.html.twig。

在我的樹枝線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.^]+'

但它不匹配。 有人可以幫忙嗎?

謝謝...

就像@Coussinsky所說,你的field “nom”的某些values在你的數據庫中是空的。

如果需要,可以將此參數設置null ,或者只更改數據庫中的空值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM