0

我刚开始使用 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 类中的一些选定(不是全部)字段合并到人员屏幕中,但现在不知道如何使用两者都可用的方法来做到这一点。任何帮助深表感谢。

4

1 回答 1

1

AbstractScreenaddFields方法可以添加单个字段,也可以添加Record对象中的所有字段。这适用于LiftScreenWizardScreen

// 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
  }
}
于 2012-06-13T13:28:12.790 回答