Note the SHtml.hidden function is defined as:

def hidden(func: () => Any, attrs: (String, String)*): Elem =
makeFormElement("hidden", NFuncHolder(func), attrs :_*) % ("value" ->
"true")

see that it automatically puts value = true.

It used to accept a function like (String) => Any but I'm not sure why
it doesn't anymore. Probably to "enforce" the usage of hidden fields
to act as flags instead of actual data. Nonetheless I still think we
should overload hidden function to accept the String value ..like:

def hidden(func: (String) => Any, attrs: (String, String)*): Elem =

Anyways in the mean time you can try something like:

def hidden(func: (String) => Any, attrs: (String, String)*): Elem =
S.fmapFunc(SFuncHolder(func))(funcName =>
    attrs.foldLeft(<input type="hidden" name={funcName}/>)(_ % _))

and now your function should receive the actual value specified in the
hidden field. Note that I didn't test the above function :D ... let me
know if it works for you.

Br's,
Marius

On Apr 7, 3:15 pm, wapgui <torsten.schm...@wapgui.com> wrote:
> Thanks for the reply I found the js solution this night too, but the
> delivery of messages on google groups seems to be very slow (Now 6
> hours pending).
> Now I have only left one little problem.
> This should give me the value : "color" -> hidden(() => fp.color) %
> ("id" -> "color"). But it's empty and the definition of hidden allows
> only () => fp.color not fp.color = _ like on text for example. May be
> my scala skill is not good enough to find a solution.
>
> Cheers
> Torsten
>
> On Apr 7, 8:56 am, "marius d." <marius.dan...@gmail.com> wrote:
>
> > On Apr 6, 10:05 pm, wapgui <torsten.schm...@wapgui.com> wrote:
>
> > > Did you mean something like that ?
> > > "color" -> hidden(() => fp.color) % ("id" -> "color")
>
> > Yes
>
> > > But how can I get the value of the "color" and how to set the value
> > > via js if the form has no name and the name of the input is generated.
>
> > > <form method="post" action="/">
> > >                 <input value="true" type="hidden" name="F9112749168471LP"
> > > id="color" /><br />
>
> > Well knowing the unique node id you don't need the form's name or id.
> > you can just say:
>
> > $("#color").attr("value", "some value") ... using JQuery
>
> > or raw JavaScript
>
> > document.getElementById("color").value = "some value";
>
> > or using Lift's abstractions
>
> > JsCmds.SetValById("color", "some value") ... but you need to use this
> > in the context where a JsExp/JsCmd is appropriate (JS events, return a
> > JavaScript as a result of an Ajax call etc)
>
> > > It's all so difficult if there are no examples. But I will post my
> > > small experience on my website to help other newbies.
>
> > No worries it is good to ask questions.
>
> > > Cheers
> > > Torsten
>
> > > On Apr 6, 4:47 pm, "marius d." <marius.dan...@gmail.com> wrote:
>
> > > > Well putting an id to the hidden field allows you to manipulate it via
> > > > JavaScript.
>
> > > > Br's,
> > > > Marius
>
> > > > On Apr 6, 5:01 pm, wapgui <torsten.schm...@wapgui.com> wrote:
>
> > > > > Hi,
>
> > > > > is there an equivalent in lift to the hidden input filed used in
> > > > > forms. The SHtml.hidden is only for functions not for parameters, the
> > > > > value is always true. I want set the hidden input via javascript.
>
> > > > > Is there also a parameter for setting the name of the form itself?
>
> > > > > Here the code:
>
> > > > > object smlink extends RequestVar(Full(""))
>
> > > > > var fp = new Widget()
>
> > > > >   def show(xhtml: NodeSeq): NodeSeq = {
> > > > >     val temp =
> > > > >       if (smlink.isEmpty || smlink.open_!.length == 0) "" else
> > > > > "Received: " + smlink.open_!
>
> > > > >     bind("fp", xhtml,
> > > > >       "color" -> hidden({() => fp.color}),
> > > > >       "title" -> text(fp.title, fp.title = _) % ("size" -> "10") %
> > > > > ("id" -> "title"),
> > > > >       "url" -> text(fp.url, fp.url = _) % ("size" -> "56") % ("id" ->
> > > > > "url"),
> > > > >       "items" -> select((1 to 9).toList.reverse.map(v => (v.toString,
> > > > > v.toString)),
> > > > >                         Empty, fp.items = _),
> > > > >       "submit" -> submit("Send", () => {
> > > > >         Log.info("Submitted ")
> > > > >         smlink(Full(fp.title))
> > > > >       }),
> > > > >       "link" -> <div>{temp}</div>
> > > > >     )
> > > > >   }
>
> > > > > generates this:
>
> > > > > <form method="post" action="/">
> > > > >         <input name="F1142516722376UOU" type="hidden" value="true" 
> > > > > /><br />
> > > > >         <label for="title">Title</label>
> > > > >         <input size="10" name="F1142516722377UCO" type="text" value=""
> > > > > id="title" /><br />
> > > > >         <label for="url">URL</label>
> > > > >         <input size="56" name="F1142516722378IZS" type="text" value=""
> > > > > id="url" /><br />
> > > > >         <label for="items">Items</label>
> > > > >         <select name="F1142516722379K2S"><option value="9">9</
> > > > > option><option value="8">8</option><option value="7">7</option><option
> > > > > value="6">6</option><option value="5">5</option><option value="4">4</
> > > > > option><option value="3">3</option><option value="2">2</option><option
> > > > > value="1">1</option></select><br />
> > > > >         <input name="F1142516722380W2M" type="submit" value="Send" />
> > > > >         <div></div>
> > > > >         </form>
>
> > > > > Cheers
> > > > > Torsten
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to