[英]Passing variable/rc on form submit without using hidden inputs in Coldfusion/Coldbox
我已經嘗試了一百萬種方法,所以我想我會崩潰然后問
通常,我的設置是一個具有不同事件的處理程序,用於編輯視圖,並保存用於表單提交
function edit(event, rc, prc) {
rc.query=getmodel("somemodel").getlist(rc.unique);
}
function save(event, rc, prc){
event.norender();
getPlugin("MessageBox").info("#rc.allocation# Saved");
setNextEvent(event="myhandler.edit", url="edit?unique=#rc.allocation#");
}
在編輯視圖上,像這樣的URL myhandler / edit?unique = 99,我有一個表單來設置保存事件,如下所示
<form action="#event.buildLink('myhandler.save">
本質上創建了保存事件的鏈接
現在除非我在這樣的表單中設置隱藏的輸入
<input id="unique" name="unique" type="hidden" value="#rc.unique#"/>
我總是收到錯誤消息“ RC中未定義元素唯一”
我知道必須有一種方法可以在表單提交上傳遞參數而不將其定義為輸入,我只是找不到一個有關如何執行此操作的示例
您可以使用event.getValue()
檢索值,而不是直接檢查RC。 如果RC中不存在默認值,則可以返回該默認值:
<input id="unique" name="unique" type="hidden" value="#event.getValue("unique","defaultValue")#"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.