本文整理匯總了Golang中github.com/QLeelulu/goku/form.NewForm函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewForm函數的具體用法?Golang NewForm怎麽用?Golang NewForm使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewForm函數的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: createRecoverPasswordForm
func createRecoverPasswordForm() *form.Form {
email := form.NewEmailField("email", "Email", true).
Error("invalid", "Email地址錯誤").
Error("required", "Email地址必須填寫").Field()
form := form.NewForm(email)
return form
}
示例2: createRegForm
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
}
示例3: createBaseInfoForm
// 更新基本信息
func createBaseInfoForm() *form.Form {
description := form.NewTextField("description", "自我介紹", false).Max(100).
Error("max-length", "自我介紹的字數不能多於{0}個").Field()
name := form.NewCharField("name", "用戶名", true).Min(2).Max(15).
Error("required", "用戶名必須填寫").
Error("range", "用戶名長度必須在{0}到{1}之間").Field()
// add the fields to a form
form := form.NewForm(description, name)
return form
}
示例4: createResetPasswordForm
func createResetPasswordForm() *form.Form {
newPwd := form.NewCharField("new-pwd", "新密碼", true).Min(6).Max(30).
Error("required", "新密碼必須填寫").
Error("range", "新密碼長度必須在{0}到{1}之間").Field()
newPwd2 := form.NewCharField("new-pwd2", "確認密碼", true).Min(6).Max(30).
Error("required", "確認密碼必須填寫").
Error("range", "確認密碼長度必須在{0}到{1}之間").Field()
form := form.NewForm(newPwd, newPwd2)
return form
}
示例5: CreateLinkSubmitForm
/**
* 鏈接提交表單
*/
func CreateLinkSubmitForm() *form.Form {
title := form.NewCharField("title", "標題", true).Min(8).Max(140).
Error("required", "標題必須填寫").
Error("range", "標題長度必須在{0}到{1}之間").Field()
context := form.NewRegexpField("context", "URL地址", true, `http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?`).
Error("required", "URL地址必須填寫").
Error("invalid", "URL格式不正確").Field()
topics := form.NewCharField("topics", "話題", false).Field()
form := form.NewForm(title, context, topics)
return form
}
示例6: createCreateAndBindForm
func createCreateAndBindForm(emailRequired bool) *form.Form {
fields := []form.Field{}
name := createNameField()
fields = append(fields, name)
if emailRequired {
email := createEmailField()
fields = append(fields, email)
}
form := form.NewForm(fields...)
return form
}
示例7: createLoginForm
/**
* form
*/
func createLoginForm() *form.Form {
// defined the field
email := createEmailField()
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
}
示例8: NewCommentSubmitForm
/**
* 評論提交表單
*/
func NewCommentSubmitForm() *form.Form {
content := form.NewTextField("content", "內容", true).Min(8).
Error("required", "內容必須填寫").
Error("min", "內容長度必須大於{0}").Field()
linkId := form.NewIntegerField("link_id", "鏈接id", true).Min(1).
Error("required", "鏈接ID必須填寫").
Error("invalid", "鏈接ID不正確").Field()
parentId := form.NewIntegerField("parent_id", "父評論id", false).
Error("invalid", "父評論ID不正確").Field()
form := form.NewForm(linkId, parentId, content)
return form
}
示例9: createTodoForm
/**
* form
*/
func createTodoForm() *form.Form {
// defined the field
id := form.NewIntegerField("id", "Id", false).Range(1, 10).
// {0} will replace with the min range value,
// {1} will replace with the max range value,
Error("range", "值必須在{0}到{1}之間").Field()
// title
title := form.NewTextField("title", "待辦事項", true).Min(8).Max(200).
Error("required", "必須填寫事項內容").
Error("range", "字數必須在{0}到{1}之間").Field()
// add the fields to a form
form := form.NewForm(id, title)
return form
}
示例10: createUpdatePwdForm
// 更新密碼
func createUpdatePwdForm() *form.Form {
oldPwd := form.NewCharField("old-pwd", "原密碼", true).Min(6).Max(30).
Error("required", "原密碼必須填寫").
Error("range", "原密碼長度必須在{0}到{1}之間").Field()
newPwd := form.NewCharField("new-pwd", "新密碼", true).Min(6).Max(30).
Error("required", "新密碼必須填寫").
Error("range", "新密碼長度必須在{0}到{1}之間").Field()
newPwd2 := form.NewCharField("new-pwd2", "確認密碼", true).Min(6).Max(30).
Error("required", "確認密碼必須填寫").
Error("range", "確認密碼長度必須在{0}到{1}之間").Field()
// add the fields to a form
form := form.NewForm(oldPwd, newPwd, newPwd2)
return form
}
示例11:
}).
/**
* 新浪微博登錄,提交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()
// 檢查email地址是否已經注冊
emailExist := models.User_IsEmailExist(m["email"].(string))
userExist := models.User_IsUserExist(m["name"].(string))
if !emailExist && !userExist {
m["reference_id"] = ctx.Get("uid")
m["reference_system"] = 1
m["reference_token"] = ctx.Get("token")
m["create_time"] = time.Now()
result, err := models.User_SaveMap(m) // TODO:
示例12: createRecoverPasswordForm
func createRecoverPasswordForm() *form.Form {
email := createEmailField()
form := form.NewForm(email)
return form
}