Search code examples
scalalift

Lift: how to build forms with designer friendly templates?


As a test, I'm trying to create a form in lift with a designer friendly template. I'm using Lift 2.5

I already managed to create a working form using toForm, but I'm just exploring all possible ways.

My html file contains the code below:

...
<span class="lift:Util.entry?form=post">
  <span id="etitle"></span>
  <span id="ebody"></span>
  <span id="esubmit"></span>
</span>
...

And in my Util.scala I defined the entry snippet like below:

def entry = {
  "#etitle *" #> SHtml.text(title, title = _)
  "#ebody *" #> SHtml.text(body, body = _)
  "#submit *" #> SHtml.submit("Save", saveEntry)
}

All the spans remain empty; what am I doing wrong?

Thanks!


Solution

  • Didn't you forget to merge the transformations ( #> ) with the ampersand ( & ) ?

    def entry = {
      "#etitle *" #> SHtml.text(title, title = _) &
        "#ebody *" #> SHtml.text(body, body = _) &
        "#esubmit *" #> SHtml.submit("Save", saveEntry)
    }