質問

追加と編集フォームを含むキャッスルモノレールベースのサイトにいくつかの追加を書いています。 ADDフォームは正常に機能し、投稿を使用しますが、編集フォームはGETを使用します。私が見ることができる唯一の大きな違いは、編集方法がクエリ文字列で編集されているオブジェクトのIDで呼び出されることです。編集フォームに[送信]ボタンが押された場合、渡された引数のみはこのオブジェクトIDです。編集フォームのコードは次のとおりです。

<form action="edit.ashx" method="post">
<h3>Coupon Description</h3>
<textarea name="comments" width="200">$comments</textarea>
<br/><br/>
<h3>Coupon Actions</h3>
<br/>
<div>Give Stories</div>

<ul class="checklist" style="overflow:auto;height:144px;width:100%">
#foreach ($story in $stories.Values)
    <li>
    <label>
    #set ($associated = "")
    #foreach($storyId in $storyIds)
        #if($story.Id == $storyId)
            #set($associated = " checked='true'")
        #end
    #end
    <input type="checkbox" name="chk_${story.Id}" id="chk_${story.Id}" value="true" class="checkbox" $associated/>
    $story.Name
</label>
</li>
#end
</ul>
    <br/><br/>
<div>Give Credit Amount</div>
<input type="text" name="credit" value="$credit" />
<br/><br/>

<h3>Coupon Uses</h3>
<input type="checkbox" name="multi" #if($multi) checked="true" #end /> Multi-Use Coupon?<br/><br/>
<b>OR</b>
<br/>
<br/>
Number of Uses per Coupon: <input type="text" name="uses" value="$uses" />
<br/>

<input type="submit" name="Save" />

</form>

これとADDフォームの違いは、関連性とプロパティバッグからの入力の値に関係する速度の容量です。

コントローラーでこれを扱う方法は、次のように始まります。

public void Edit(int id)
{
    Coupon coupon = Coupon.GetRepository(User.Site.Id).FindById(id).Value;
    if(coupon == null) {
        RedirectToReferrer();
        return;
    }

    IFutureQueryOfList<Story> stories = Story.GetRepository(User.Site.Id).OnlyReturnEnabled().FindAll("Name", true);

    if (Params["Save"] == null)
    {
        ...
    }
}

確実に呼び出されますが、パラメージのブレークポイント["save"]を使用すると、httpmethodが「get」であり、渡された唯一の引数(フォームとリクエスト)がオブジェクトIDと追加のHTTPヘッダーであることがわかります。

結局のところ、私はモノレールにそれほど精通していません。これは私に代わって愚かな間違いかもしれませんが、それが問題を解決した場合、私は非常に馬鹿にされてくれてとても感謝しています! :)

ありがとう

役に立ちましたか?

解決

コントローラーに個別のメソッドを使用して、フォームのロードとその提出物を処理するために、クーポンを保存するのではなく、クーポンを保存することでこれを回避しました。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top