示例#1
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
}
示例#2
0
文件: todo.go 项目: hoysoft/goku
/**
 * 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
}
示例#3
0
文件: todo.go 项目: huwenshu/goku
/**
 * 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
}