简体   繁体   中英

Passing variable/rc on form submit without using hidden inputs in Coldfusion/Coldbox

ve tried this a million ways, So i figured i would just break down and ask

typically, my setup is a handler with different events for edit view, and save for form submit

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#");
    }

on the edit view, url like this myhandler/edit?unique=99 , i have a form that sets the event of save like this

<form  action="#event.buildLink('myhandler.save">

which essentially creates the link to the save event

Now unless i set a hidden input in my form like this

<input id="unique" name="unique" type="hidden" value="#rc.unique#"/> 

I always get an Error "Element UNIQUE is undefined in RC"

I know there has got to be a way to be able to pass a parameter on form submit without it being defined as an input, i just cannot find a single example on how todo so

You can use event.getValue() to retrieve a value instead of checking RC directly. This allows you to return a default value if it doesn't exist in RC:

<input id="unique" name="unique" type="hidden" value="#event.getValue("unique","defaultValue")#"/> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM