Exemple #1
0
func createRecoverPasswordForm() *form.Form {
	email := form.NewEmailField("email", "Email", true).
		Error("invalid", "Email地址错误").
		Error("required", "Email地址必须填写").Field()
	form := form.NewForm(email)
	return form
}
Exemple #2
0
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
}
Exemple #3
0
// 更新基本信息
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
}
Exemple #4
0
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
}
Exemple #5
0
/**
 * 链接提交表单
 */
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
}
Exemple #6
0
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
}
Exemple #7
0
/**
 * 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
}
Exemple #8
0
/**
 * 评论提交表单
 */
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
}
Exemple #9
0
/**
 * 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
}
Exemple #10
0
/**
 * 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", "Value must between {0} and {1}").Field()
	// title
	title := form.NewTextField("title", "todo", true).Min(8).Max(200).
		Error("required", "Must write what to do").
		Error("range", "Words must between {0} and {1}").Field()

	// add the fields to a form
	form := form.NewForm(id, title)
	return form
}
Exemple #11
0
// 更新密码
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
}
Exemple #12
0
	}).
	/**
	 * 新浪微博登录,提交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:
Exemple #13
0
func createRecoverPasswordForm() *form.Form {
	email := createEmailField()
	form := form.NewForm(email)
	return form
}