package code
package snippet

import net.liftweb.http._
import net.liftweb.util.Helpers._

import com.hacklanta.formality._
  import Formality._
  import Html5Validations._

import model.User

object Signup {
  import net.liftweb.sitemap._
    import Loc._

  val menu =
    Menu.i("signup") / "signup" >>
      If(
        LoginHelpers.notLoggedIn_? _,
        () => RedirectResponse("/")
      )

  val loc = menu.loc
}
class Signup {
  def form = {
    val emailField = field[String]("#email") ? notEmpty
    val passwordField = field[String]("#password") ? notEmpty

    val registrationForm =
      Formality.form withField
        emailField withField passwordField formalize() onSuccess {
          case email :+: password :+: HNil =>
            LoginHelpers.logUserIn(User.create(User(email, password)))

            S.redirectTo("/")
      }

    "form" #> registrationForm.binder()
  }
}


package code
package snippet

import net.liftweb.http._
import net.liftweb.util.Helpers._

import com.hacklanta.formality.Formality
  import Formality._

import model.User

object Signup {
  import net.liftweb.sitemap._
    import Loc._

  val menu =
    Menu.i("signup") / "signup" >>
      If(
        LoginHelpers.notLoggedIn_? _,
        () => RedirectResponse("/")
      )

  val loc = menu.loc
}
class Signup {
  def form = {
    val registrationForm =
      Formality.form withField
        field[String]("#email") withField
        field[String]("#password") formalize() onSuccess {
          case email :+: password :+: HNil =>
            LoginHelpers.logUserIn(User.create(User(email, password)))

            S.redirectTo("/")
      }

    "form" #> registrationForm.binder()
  }
}


--- 
+++ 
@@ -4,8 +4,9 @@
 import net.liftweb.http._
 import net.liftweb.util.Helpers._
 
-import com.hacklanta.formality.Formality
+import com.hacklanta.formality._
   import Formality._
+  import Html5Validations._
 
 import model.User
 
@@ -24,10 +25,12 @@
 }
 class Signup {
   def form = {
+    val emailField = field[String]("#email") ? notEmpty
+    val passwordField = field[String]("#password") ? notEmpty
+
     val registrationForm =
       Formality.form withField
-        field[String]("#email") withField
-        field[String]("#password") formalize() onSuccess {
+        emailField withField passwordField formalize() onSuccess {
           case email :+: password :+: HNil =>
             LoginHelpers.logUserIn(User.create(User(email, password)))
 
Add not-blank validations to email and password fields.
