Esempio n. 1
0
func (f TextField) FormWidget(locale string, field *FieldConfig) htmlwidgets.Widget {
	G, _, _, _ := gettext.DefaultLocales.Use("", locale)
	widget := new(htmlwidgets.TextWidget)
	if field.Required {
		widget.MinLength = 1
		widget.ValidationError = G("Required.")
	}
	return widget
}
Esempio n. 2
0
func (t TextField) ToFormField(form *htmlwidgets.Form, data NestedMap,
	field *FieldConfig, locale string) {
	data.Set(field.Id, string(t))
	G, _, _, _ := gettext.DefaultLocales.Use("", locale)
	widget := new(htmlwidgets.TextWidget)
	if field.Required {
		widget.MinLength = 1
		widget.ValidationError = G("Required.")
	}
	form.AddWidget(widget, "Fields."+field.Id, field.Name.Get(locale), "")
}