func createRegForm() *form.Form { key := form.NewCharField("key", "邀请码", true). Error("required", "邀请码必须填写").Field() email := form.NewEmailField("email", "Email", true). Error("invalid", "Email地址错误"). Error("required", "Email地址必须填写").Field() pwd := form.NewCharField("pwd", "密码", true).Min(6).Max(30). Error("required", "密码必须填写"). Error("range", "密码长度必须在{0}到{1}之间").Field() name := form.NewCharField("name", "昵称", true).Min(2).Max(15). Error("required", "昵称必须填写"). Error("range", "昵称长度必须在{0}到{1}之间").Field() repwd := form.NewCharField("repwd", "确认密码", true).Min(6).Max(30). Error("required", "确认密码必须填写"). Error("range", "密码长度必须在{0}到{1}之间").Field() // add the fields to a form form := form.NewForm(key, email, name, pwd, repwd) return form }
func createRecoverPasswordForm() *form.Form { email := form.NewEmailField("email", "Email", true). Error("invalid", "Email地址错误"). Error("required", "Email地址必须填写").Field() form := form.NewForm(email) return form }
/** * form */ func createLoginForm() *form.Form { // defined the field email := form.NewEmailField("email", "Email", true). Error("invalid", "Email地址错误"). Error("require", "Email地址必须填写").Field() pwd := form.NewCharField("pwd", "密码", true).Min(6).Max(30). Error("required", "密码必须填写"). Error("range", "密码长度必须在{0}到{1}之间").Field() remeber_me := form.NewCharField("remeber_me", "记住我", false) // add the fields to a form form := form.NewForm(email, pwd, remeber_me) return form }
} else { //让用户填补用户名\email ctx.ViewData["screenname"] = sinaUser.Screen_Name ctx.ViewData["token"] = token.Access_Token ctx.ViewData["uid"] = token.Uid ctx.ViewData["expires"] = token.Expires_In } return ctx.Render("oauthcallback", nil) }). /** * 新浪微博登录,提交email和昵称 */ Post("sinaoauthcallback", func(ctx *goku.HttpContext) goku.ActionResulter { email := form.NewEmailField("email", "Email", true). Error("invalid", "Email地址错误"). Error("required", "Email地址必须填写").Field() name := form.NewCharField("name", "昵称", true).Min(2).Max(15). Error("required", "昵称必须填写"). Error("range", "昵称长度必须在{0}到{1}之间").Field() // add the fields to a form f := form.NewForm(email, name) f.FillByRequest(ctx.Request) errorMsgs := make([]string, 0) userId := int64(0) if f.Valid() { m := f.CleanValues()
func createEmailField() form.Field { email := form.NewEmailField("email", "Email", true). Error("invalid", "Email地址错误"). Error("required", "Email地址必须填写").Field() return email }