Hi,
there is .toForm in every Mapper field. How do you do this (create forms from models) in JPA models?
Thanks in advance, Etam.
Hi,
there is .toForm in every Mapper field. How do you do this (create forms from models) in JPA models?
Thanks in advance, Etam.
The snarky answer is you write the code. The less snarky answer is, look at the code and follow that as an example.
There is no built in (to lift) way to convert a class to a form. You'll have to write the code yourself, using scala's native ability to handle html.
Something like this:
def toForm = <form><label>Field 1</label><input>{field1}</form>
You can either then process the form using snippets, or the Lift method of your choice.
Is this a good idea:
class Company extends DAO with Logging {
var name = "Initial name"
var email = "Initial e-mail"
def save:Unit = {
dao.store(this)
info("Saving %s".format(this.toString))
}
def addForm(in: NodeSeq): NodeSeq = {
bind("company", in,
"name" -> text(name, name = _),
"email" -> text(email, email = _),
"save" -> submit("Save", save),
)
}
override def toString() = "Company %s".format(name)
}
, or there is another, simpler way?
Thanks in advance, Etam.