Documentation ¶
Index ¶
- Variables
- func InitForm(form Form) error
- func IsFieldValid(f Field, rawValue interface{}) bool
- func IsFormSelfValid(form Form) bool
- func IsFormValid(form Form, formValues url.Values) bool
- func IsMultipartFormValid(form Form, multipartForm *multipart.Form) bool
- func IsValid(f Form, getValue valueGetterFunc) bool
- func Register(field Field, constr constructor)
- func Render(field Field, attrs ...string) (template.HTML, error)
- func RenderError(f Field) (template.HTML, error)
- func RenderErrors(form Form) (template.HTML, error)
- func RenderField(f Field, attrs ...string) (template.HTML, error)
- func RenderHiddenFields(form Form) (template.HTML, error)
- func RenderLabel(f Field) (template.HTML, error)
- type BaseField
- func (f *BaseField) AddValidator(validator Validator)
- func (f *BaseField) ApplyValidators(rawValue interface{}) error
- func (f *BaseField) HasLabel() bool
- func (f *BaseField) HasName() bool
- func (f *BaseField) HasValidationError() bool
- func (f *BaseField) IsMulti() bool
- func (f *BaseField) IsMultipart() bool
- func (f *BaseField) IsRequired() bool
- func (f *BaseField) Label() string
- func (f *BaseField) Name() string
- func (f *BaseField) RawValue() interface{}
- func (f *BaseField) Render(attrs ...string) template.HTML
- func (f *BaseField) Reset()
- func (f *BaseField) SetIsMulti(flag bool)
- func (f *BaseField) SetIsMultipart(flag bool)
- func (f *BaseField) SetIsRequired(flag bool)
- func (f *BaseField) SetLabel(label string)
- func (f *BaseField) SetName(name string)
- func (f *BaseField) SetValidationError(err error)
- func (f *BaseField) SetWidget(widget Widget)
- func (f *BaseField) StringValue() string
- func (f *BaseField) ValidationError() error
- func (f *BaseField) Widget() Widget
- type BaseForm
- type BaseWidget
- type BoolField
- type CheckboxWidget
- type ChoiceWidget
- type Field
- type FileField
- type FileWidget
- type Form
- type HiddenWidget
- type Int64Choice
- type Int64ChoiceField
- type Int64ChoicesValidator
- type Int64Field
- type MultiInt64ChoiceField
- func (f *MultiInt64ChoiceField) Render(attrs ...string) template.HTML
- func (f *MultiInt64ChoiceField) SetInitial(initial []int64)
- func (f *MultiInt64ChoiceField) StringValue() []string
- func (f *MultiInt64ChoiceField) Validate(rawValue interface{}) error
- func (f *MultiInt64ChoiceField) Value() []int64
- type MultiStringChoiceField
- func (f *MultiStringChoiceField) Render(attrs ...string) template.HTML
- func (f *MultiStringChoiceField) SetInitial(initial []string)
- func (f *MultiStringChoiceField) StringValue() []string
- func (f *MultiStringChoiceField) Validate(rawValue interface{}) error
- func (f *MultiStringChoiceField) Value() []string
- type MultiValueField
- type RadioWidget
- type SelectWidget
- type SingleValueField
- type StringChoice
- type StringChoiceField
- type StringChoicesValidator
- type StringField
- type TextWidget
- type TextareaStringField
- type TextareaWidget
- type Validator
- type Widget
- type WidgetAttrs
- func (w *WidgetAttrs) Clone() *WidgetAttrs
- func (w *WidgetAttrs) FromSlice(attrs []string)
- func (w *WidgetAttrs) Get(name string) (string, bool)
- func (w *WidgetAttrs) Names() []string
- func (w *WidgetAttrs) Pop(name string) (string, bool)
- func (w *WidgetAttrs) Set(name, value string)
- func (w *WidgetAttrs) String() string
Constants ¶
This section is empty.
Variables ¶
View Source
var ( WidgetTemplatePath = rootDir() + "templates/gforms/widget.html" CheckboxTemplatePath = rootDir() + "templates/gforms/checkbox.html" RadioTemplatePath = rootDir() + "templates/gforms/radio.html" )
View Source
var (
ErrRequired = errors.New("This field is required")
)
Functions ¶
func IsFieldValid ¶
func IsFormSelfValid ¶
func IsMultipartFormValid ¶
Types ¶
type BaseField ¶
type BaseField struct {
// contains filtered or unexported fields
}
func (*BaseField) AddValidator ¶
func (*BaseField) ApplyValidators ¶
func (*BaseField) HasValidationError ¶
func (*BaseField) IsMultipart ¶
func (*BaseField) IsRequired ¶
func (*BaseField) SetIsMulti ¶
func (*BaseField) SetIsMultipart ¶
func (*BaseField) SetIsRequired ¶
func (*BaseField) SetValidationError ¶
func (*BaseField) StringValue ¶
func (*BaseField) ValidationError ¶
type BaseWidget ¶
type BaseWidget struct { HTML string // contains filtered or unexported fields }
func (*BaseWidget) Attrs ¶
func (w *BaseWidget) Attrs() *WidgetAttrs
func (*BaseWidget) IsHidden ¶
func (w *BaseWidget) IsHidden() bool
type BoolField ¶
type BoolField struct {
*BaseField
}
func NewBoolField ¶
func NewBoolField() *BoolField
func (*BoolField) SetInitial ¶
type CheckboxWidget ¶
type CheckboxWidget struct {
*BaseWidget
}
func NewCheckboxWidget ¶
func NewCheckboxWidget() *CheckboxWidget
type ChoiceWidget ¶
type Field ¶
type Field interface { Validator HasName() bool SetName(string) Name() string HasLabel() bool SetLabel(string) Label() string SetWidget(Widget) Widget() Widget SetIsMulti(bool) IsMulti() bool SetIsMultipart(bool) IsMultipart() bool SetIsRequired(bool) IsRequired() bool AddValidator(Validator) ApplyValidators(interface{}) error HasValidationError() bool SetValidationError(error) ValidationError() error RawValue() interface{} Reset() Render(...string) template.HTML }
type FileField ¶
type FileField struct {
*BaseField
}
func NewFileField ¶
func NewFileField() *FileField
func (*FileField) SetInitial ¶
func (f *FileField) SetInitial(initial *multipart.FileHeader)
func (*FileField) Value ¶
func (f *FileField) Value() *multipart.FileHeader
type FileWidget ¶
type FileWidget struct {
*BaseWidget
}
func NewFileWidget ¶
func NewFileWidget() *FileWidget
type HiddenWidget ¶
type HiddenWidget struct {
*BaseWidget
}
func NewHiddenWidget ¶
func NewHiddenWidget() *HiddenWidget
func (*HiddenWidget) IsHidden ¶
func (w *HiddenWidget) IsHidden() bool
type Int64Choice ¶
type Int64ChoiceField ¶
type Int64ChoiceField struct {
*Int64Field
}
func NewRadioInt64Field ¶
func NewRadioInt64Field() *Int64ChoiceField
func NewSelectInt64Field ¶
func NewSelectInt64Field() *Int64ChoiceField
func (*Int64ChoiceField) SetChoices ¶
func (f *Int64ChoiceField) SetChoices(choices []Int64Choice)
type Int64ChoicesValidator ¶
type Int64ChoicesValidator struct {
Choices []Int64Choice
}
func NewInt64ChoicesValidator ¶
func NewInt64ChoicesValidator(choices []Int64Choice) *Int64ChoicesValidator
func (*Int64ChoicesValidator) Validate ¶
func (v *Int64ChoicesValidator) Validate(rawValue interface{}) error
type Int64Field ¶
type Int64Field struct {
*BaseField
}
func NewInt64Field ¶
func NewInt64Field() *Int64Field
func (*Int64Field) SetInitial ¶
func (f *Int64Field) SetInitial(initial int64)
func (*Int64Field) Validate ¶
func (f *Int64Field) Validate(rawValue interface{}) error
func (*Int64Field) Value ¶
func (f *Int64Field) Value() int64
type MultiInt64ChoiceField ¶
type MultiInt64ChoiceField struct {
*Int64ChoiceField
}
func NewMultiSelectInt64Field ¶
func NewMultiSelectInt64Field() *MultiInt64ChoiceField
func (*MultiInt64ChoiceField) Render ¶
func (f *MultiInt64ChoiceField) Render(attrs ...string) template.HTML
func (*MultiInt64ChoiceField) SetInitial ¶
func (f *MultiInt64ChoiceField) SetInitial(initial []int64)
func (*MultiInt64ChoiceField) StringValue ¶
func (f *MultiInt64ChoiceField) StringValue() []string
func (*MultiInt64ChoiceField) Validate ¶
func (f *MultiInt64ChoiceField) Validate(rawValue interface{}) error
func (*MultiInt64ChoiceField) Value ¶
func (f *MultiInt64ChoiceField) Value() []int64
type MultiStringChoiceField ¶
type MultiStringChoiceField struct {
*StringChoiceField
}
func NewMultiSelectStringField ¶
func NewMultiSelectStringField() *MultiStringChoiceField
func (*MultiStringChoiceField) Render ¶
func (f *MultiStringChoiceField) Render(attrs ...string) template.HTML
func (*MultiStringChoiceField) SetInitial ¶
func (f *MultiStringChoiceField) SetInitial(initial []string)
func (*MultiStringChoiceField) StringValue ¶
func (f *MultiStringChoiceField) StringValue() []string
func (*MultiStringChoiceField) Validate ¶
func (f *MultiStringChoiceField) Validate(rawValue interface{}) error
func (*MultiStringChoiceField) Value ¶
func (f *MultiStringChoiceField) Value() []string
type MultiValueField ¶
type MultiValueField interface {
StringValue() []string
}
type RadioWidget ¶
type RadioWidget struct { *BaseWidget // contains filtered or unexported fields }
func NewRadioWidget ¶
func NewRadioWidget() *RadioWidget
func (*RadioWidget) Radios ¶
func (w *RadioWidget) Radios(attrs []string, checkedValue string) []template.HTML
func (*RadioWidget) Render ¶
func (w *RadioWidget) Render(attrs []string, checkedValues ...string) template.HTML
func (*RadioWidget) SetChoices ¶
func (w *RadioWidget) SetChoices(choices [][2]string)
type SelectWidget ¶
type SelectWidget struct { *BaseWidget // contains filtered or unexported fields }
func NewMultiSelectWidget ¶
func NewMultiSelectWidget() *SelectWidget
func NewSelectWidget ¶
func NewSelectWidget() *SelectWidget
func (*SelectWidget) Options ¶
func (w *SelectWidget) Options(selValues ...string) []string
func (*SelectWidget) Render ¶
func (w *SelectWidget) Render(attrs []string, values ...string) template.HTML
func (*SelectWidget) SetChoices ¶
func (w *SelectWidget) SetChoices(choices [][2]string)
type SingleValueField ¶
type SingleValueField interface {
StringValue() string
}
type StringChoice ¶
type StringChoiceField ¶
type StringChoiceField struct {
*StringField
}
func NewRadioStringField ¶
func NewRadioStringField() *StringChoiceField
func NewSelectStringField ¶
func NewSelectStringField() *StringChoiceField
func (*StringChoiceField) SetChoices ¶
func (f *StringChoiceField) SetChoices(choices []StringChoice)
type StringChoicesValidator ¶
type StringChoicesValidator struct {
Choices []StringChoice
}
func NewStringChoicesValidator ¶
func NewStringChoicesValidator(choices []StringChoice) *StringChoicesValidator
func (*StringChoicesValidator) Validate ¶
func (v *StringChoicesValidator) Validate(rawValue interface{}) error
type StringField ¶
func NewStringField ¶
func NewStringField() *StringField
func (*StringField) SetInitial ¶
func (f *StringField) SetInitial(initial string)
func (*StringField) Validate ¶
func (f *StringField) Validate(rawValue interface{}) error
func (*StringField) Value ¶
func (f *StringField) Value() string
type TextWidget ¶
type TextWidget struct {
*BaseWidget
}
func NewTextWidget ¶
func NewTextWidget() *TextWidget
type TextareaStringField ¶
type TextareaStringField struct {
*StringField
}
func NewTextareaStringField ¶
func NewTextareaStringField() *TextareaStringField
type TextareaWidget ¶
type TextareaWidget struct {
*BaseWidget
}
func NewTextareaWidget ¶
func NewTextareaWidget() *TextareaWidget
type WidgetAttrs ¶
type WidgetAttrs struct {
// contains filtered or unexported fields
}
func (*WidgetAttrs) Clone ¶
func (w *WidgetAttrs) Clone() *WidgetAttrs
func (*WidgetAttrs) FromSlice ¶
func (w *WidgetAttrs) FromSlice(attrs []string)
func (*WidgetAttrs) Names ¶
func (w *WidgetAttrs) Names() []string
func (*WidgetAttrs) Set ¶
func (w *WidgetAttrs) Set(name, value string)
func (*WidgetAttrs) String ¶
func (w *WidgetAttrs) String() string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.