In this recipe, we'll learn the basic technique for creating forms. Lift offers a neat and easy mechanism to help the creation of forms, called LiftScreen.
We'll modify the code that we used in the recipe, Sending e-mails using Gmail's SMTP server, in Chapter 1, Getting Started with Lift Basics.
You can duplicate and rename the code that we created before to keep the original example, or you can modify it during this recipe.
Replace the
p
tag and its contents in theindex.html
file with the following code:<div class="lift:SinglePageForm"></div>
Create a file called
SinglePageForm.scala
in thesnippet
package; it should contain the following code:package code.snippet import net.liftweb.http._ import code.lib.SendEmail class SinglePageForm extends LiftScreen { val from = field("E-mail", "", "placeholder" -> "Enter your e-mail") val subject = field("Subject", "", "placeholder" -> "Enter the subject of your message") val body ...