我刚刚开始使用scala和lift,并且因为将MegaProtoUser中的表单字段合并到向导屏幕而感到有些困惑。
我有以下MegaProtoUser代码:
object User extends User
with MongoMetaRecord[User]
with MetaMegaProtoUser[User] {
override def skipEmailValidation = true
}
class User private () extends MongoRecord[User]
with MegaProtoUser[User] {
def meta = User
//protected methods ...
}
我的向导设置如下所示:
object SignupWizard extends Wizard {
object completeInfo extends WizardVar(false)
val person = new Screen {
//Incoroporate MegaProtoUser fields here ...
override def nextScreen = {
business
}
}
val business = new Screen {
val business = field("Business name","")
}
def finish() {
S.notice("Thank you for registering!")
completeInfo.set(true)
}
}
我想将MegaProtoUser类中的一些选定(不是全部)字段合并到人员屏幕中,但现在不知道如何使用两者可用的方法执行此操作。非常感谢任何帮助。
答案 0 :(得分:1)
AbstractScreen
的{{3}}方法可以添加单个字段,也可以添加Record
对象中的所有字段。这适用于addFields
和LiftScreen
。
// assuming you just want to create a new user
object user extends WizardVar(User.createRecord)
val person = new Screen {
// addFields(() => user.is) would add all fields
addFields(() => user.is.email)
addFields(() => user.is.password)
addFields(() => user.is.timezone)
override def nextScreen = {
business
}
}