私はsymfony2.0に次のような小枝のパス関数で生成されたリンクを持っています:
<a id="aBtn" href="{{ path("SomeController_someControllerAction",{'section_id':
section_id, 'period_id': period.getId }) }}>A link</a>
また、ユーザーがページのセクションを変更するたびに、生成されたURLの「section_id」部分を更新するJavaScriptもあります。
function updateSectionId(id){
var aBtn = $("#aBtn");
var href = aBtn.attr('href');
var splitted = href.split("/");
splitted[splitted.length-2] = id; //My routing puts the period_id at that position
//(Yes i know its pretty hardcoded...)
aBtn.attr('href',splitted.join("/"));
}
確認しました。リンクは対応するsection_idで更新されます。
ただし、この要求を受け取るアクションをデバッグすると、常にsection_id=1を受け取ることがわかります。
public function newQuestionDialogAction($period_id, $section_id){
//$period_id = 1 ALWAYS, regardless of href value on the link.
私は本当に無知です...私は小枝のルート生成に何かが欠けていますか?
編集:これがルート構成です
SomeController_someControllerAction:
pattern: /{period_id}/section/{section_id}/someControllerAction
defaults: { _controller: "SomeBundle:SomeController:someControllerAction" }
requirements:
_method: GET
EDIT2:この問題の原因は、サーバーへのajaxリクエストの実行に使用されるjquery-bootstrapプラグイン「Modal2」にあると思います。問題が見つかったらお知らせします。ありがとう!