func (f *Field) RemoveClass(class string) FieldInterface {
	f.Classes.Remove(class)
	return f
}
RemoveClass removes a class from the field, if it was present.
package fields
import (
	"fmt"
	"html/template"
	"strconv"
	"strings"
	"github.com/coscms/forms/common"
	"github.com/coscms/forms/config"
	"github.com/coscms/forms/widgets"
)
var _ FieldInterface = &Field{}
type Field struct {
	Type         string                  `json:"type" xml:"type"`
	Template     string                  `json:"template" xml:"template"`
	CurrName     string                  `json:"currName" xml:"currName"`
	OrigName     string                  `json:"oriName" xml:"oriName"`
	Classes      common.HTMLAttrValues   `json:"classes" xml:"classes"`
	ID           string                  `json:"id" xml:"id"`
	Params       map[string]interface{}  `json:"params" xml:"params"`
	CSS          map[string]string       `json:"css" xml:"css"`
	Label        string                  `json:"label" xml:"label"`
	LabelCols    int                     `json:"labelCols" xml:"labelCols"`
	FieldCols    int                     `json:"fieldCols" xml:"fieldCols"`
	LabelClasses common.HTMLAttrValues   `json:"labelClasses" xml:"labelClasses"`
	Tags         common.HTMLAttrValues   `json:"tags" xml:"tags"`
	Value        string                  `json:"value" xml:"value"`
	Helptext     string                  `json:"helpText" xml:"helpText"`
	Errors       []string                `json:"errors,omitempty" xml:"errors,omitempty"`
	Additional   map[string]interface{}  `json:"additional,omitempty" xml:"additional,omitempty"`
	Choices      interface{}             `json:"choices,omitempty" xml:"choices,omitempty"`
	ChoiceKeys   map[string]ChoiceIndex  `json:"choiceKeys,omitempty" xml:"choiceKeys,omitempty"`
	AppendData   map[string]interface{}  `json:"appendData,omitempty" xml:"appendData,omitempty"`
	Theme        string                  `json:"theme" xml:"theme"`
	Format       string                  `json:"format,omitempty" xml:"format,omitempty"`
	Language     string                  `json:"language,omitempty" xml:"language,omitempty"`
	widget       widgets.WidgetInterface  
	data         map[string]interface{}
}
func FieldWithType(name, t string) *Field {
	return &Field{
		Type:         t,
		CurrName:     name,
		OrigName:     name,
		Classes:      common.HTMLAttrValues{},
		ID:           "",
		Params:       map[string]interface{}{},
		CSS:          map[string]string{},
		Label:        "",
		LabelClasses: common.HTMLAttrValues{},
		Tags:         common.HTMLAttrValues{},
		Value:        "",
		Helptext:     "",
		Errors:       []string{},
		Additional:   map[string]interface{}{},
		Choices:      nil,
		ChoiceKeys:   map[string]ChoiceIndex{},
		AppendData:   map[string]interface{}{},
	}
}
func (f *Field) SetTemplate(tmpl string, theme ...string) FieldInterface {
	f.Template = tmpl
	if len(f.Template) > 0 && f.widget != nil && f.Template != tmpl {
		var s string
		if len(theme) > 0 {
			s = theme[0]
		} else {
			s = f.Theme
		}
		f.widget = widgets.BaseWidget(s, f.Type, f.Template)
	}
	return f
}
func (f *Field) SetName(name string) {
	f.CurrName = name
}
func (f *Field) OriginalName() string {
	return f.OrigName
}
func (f *Field) Clone() config.FormElement {
	fc := *f
	return &fc
}
func (f *Field) SetLang(lang string) {
	f.Language = lang
}
func (f *Field) Lang() string {
	return f.Language
}
func (f *Field) SetTheme(theme string) FieldInterface {
	f.Theme = theme
	f.widget = widgets.BaseWidget(theme, f.Type, f.Template)
	return f
}
func (f *Field) SetData(key string, value interface{}) {
	f.AppendData[key] = value
}
func (f *Field) SetLabelCols(cols int) {
	f.LabelCols = cols
}
func (f *Field) SetFieldCols(cols int) {
	f.FieldCols = cols
}
func (f *Field) Name() string {
	return strings.TrimSuffix(f.CurrName, "[]")
}
func (f *Field) Data() map[string]interface{} {
	if len(f.data) > 0 {
		return f.data
	}
	safeParams := make(common.HTMLAttributes)
	safeParams.FillFrom(f.Params)
	f.data = map[string]interface{}{
		"classes":      f.Classes,
		"id":           f.ID,
		"name":         f.CurrName,
		"params":       safeParams,
		"css":          f.CSS,
		"type":         f.Type,
		"label":        f.Label,
		"labelCols":    f.LabelCols,
		"fieldCols":    f.FieldCols,
		"labelClasses": f.LabelClasses,
		"tags":         f.Tags,
		"value":        f.Value,
		"helptext":     f.Helptext,
		"errors":       f.Errors,
		"container":    "form",
		"choices":      f.Choices,
	}
	for k, v := range f.Additional {
		f.data[k] = v
	}
	for k, v := range f.AppendData {
		f.data[k] = v
	}
	return f.data
}
func (f *Field) Render() template.HTML {
	if f.widget != nil {
		return template.HTML(f.widget.Render(f.Data()))
	}
	return template.HTML("")
}
func (f *Field) String() string {
	if f.widget != nil {
		return f.widget.Render(f.Data())
	}
	return ""
}
func (f *Field) AddClass(class string) FieldInterface {
	f.Classes.Add(class)
	return f
}