gforms: github.com/liudch/gforms Index | Files | Directories

package gforms

import "github.com/liudch/gforms"

Index

Package Files

attrs.go constrinfo.go fields.go form.go formatter.go helpers.go typeinfo.go validators.go widgets.go

Variables

var (
    WidgetTemplate   = newTemplate("templates/gforms/widget.html")
    CheckboxTemplate = newTemplate("templates/gforms/checkbox.html")
    RadioTemplate    = newTemplate("templates/gforms/radio.html")
)
var (
    ErrRequired = errors.New("This field is required")
)

func InitForm Uses

func InitForm(form Form) error

func IsFieldValid Uses

func IsFieldValid(f Field, rawValue interface{}) bool

func IsFormValid Uses

func IsFormValid(form Form, formValues url.Values) bool

func IsMultipartFormValid Uses

func IsMultipartFormValid(form Form, multipartForm *multipart.Form) bool

func IsValid Uses

func IsValid(f Form, getValue valueGetterFunc) bool

func Register Uses

func Register(field Field, constr constructor)

func Render Uses

func Render(field Field, attrs ...string) (template.HTML, error)

func RenderError Uses

func RenderError(f Field) (template.HTML, error)

func RenderErrors Uses

func RenderErrors(form Form) (template.HTML, error)

func RenderField Uses

func RenderField(f Field, attrs []string) (template.HTML, error)

func RenderHiddenFields Uses

func RenderHiddenFields(form Form) (template.HTML, error)

func RenderLabel Uses

func RenderLabel(f Field) (template.HTML, error)

type BaseField Uses

type BaseField struct {
    // contains filtered or unexported fields
}

func (*BaseField) AddValidator Uses

func (f *BaseField) AddValidator(validator Validator)

func (*BaseField) ApplyValidators Uses

func (f *BaseField) ApplyValidators(rawValue interface{}) error

func (*BaseField) HasLabel Uses

func (f *BaseField) HasLabel() bool

func (*BaseField) HasName Uses

func (f *BaseField) HasName() bool

func (*BaseField) HasValidationError Uses

func (f *BaseField) HasValidationError() bool

func (*BaseField) IsMulti Uses

func (f *BaseField) IsMulti() bool

func (*BaseField) IsMultipart Uses

func (f *BaseField) IsMultipart() bool

func (*BaseField) IsRequired Uses

func (f *BaseField) IsRequired() bool

func (*BaseField) Label Uses

func (f *BaseField) Label() string

func (*BaseField) Name Uses

func (f *BaseField) Name() string

func (*BaseField) Render Uses

func (f *BaseField) Render(attrs ...string) template.HTML

func (*BaseField) Reset Uses

func (f *BaseField) Reset()

func (*BaseField) SetIsMulti Uses

func (f *BaseField) SetIsMulti(flag bool)

func (*BaseField) SetIsMultipart Uses

func (f *BaseField) SetIsMultipart(flag bool)

func (*BaseField) SetIsRequired Uses

func (f *BaseField) SetIsRequired(flag bool)

func (*BaseField) SetLabel Uses

func (f *BaseField) SetLabel(label string)

func (*BaseField) SetName Uses

func (f *BaseField) SetName(name string)

func (*BaseField) SetValidationError Uses

func (f *BaseField) SetValidationError(err error)

func (*BaseField) SetWidget Uses

func (f *BaseField) SetWidget(widget Widget)

func (*BaseField) StringValue Uses

func (f *BaseField) StringValue() string

func (*BaseField) ValidationError Uses

func (f *BaseField) ValidationError() error

func (*BaseField) Widget Uses

func (f *BaseField) Widget() Widget

type BaseForm Uses

type BaseForm struct {
    // contains filtered or unexported fields
}

func (*BaseForm) Errors Uses

func (f *BaseForm) Errors() map[string]error

func (*BaseForm) Fields Uses

func (f *BaseForm) Fields() map[string]Field

func (*BaseForm) SetErrors Uses

func (f *BaseForm) SetErrors(errors map[string]error)

func (*BaseForm) SetFields Uses

func (f *BaseForm) SetFields(fields map[string]Field)

type BaseWidget Uses

type BaseWidget struct {
    HTML string
    // contains filtered or unexported fields
}

func (*BaseWidget) Attrs Uses

func (w *BaseWidget) Attrs() *WidgetAttrs

func (*BaseWidget) IsHidden Uses

func (w *BaseWidget) IsHidden() bool

func (*BaseWidget) Render Uses

func (w *BaseWidget) Render(attrs []string, values ...string) template.HTML

type BoolField Uses

type BoolField struct {
    *BaseField
}

func NewBoolField Uses

func NewBoolField() *BoolField

func (*BoolField) Render Uses

func (f *BoolField) Render(attrs ...string) template.HTML

func (*BoolField) SetInitial Uses

func (f *BoolField) SetInitial(initial bool)

func (*BoolField) Validate Uses

func (f *BoolField) Validate(rawValue interface{}) error

func (*BoolField) Value Uses

func (f *BoolField) Value() bool

type CheckboxWidget Uses

type CheckboxWidget struct {
    *BaseWidget
}

func NewCheckboxWidget Uses

func NewCheckboxWidget() *CheckboxWidget

type ChoiceWidget Uses

type ChoiceWidget interface {
    Widget
    SetChoices(choices [][2]string)
}

type Field Uses

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

    Reset()
    Render(...string) template.HTML
}

type FileField Uses

type FileField struct {
    *BaseField
}

func NewFileField Uses

func NewFileField() *FileField

func (*FileField) Render Uses

func (f *FileField) Render(attrs ...string) template.HTML

func (*FileField) SetInitial Uses

func (f *FileField) SetInitial(initial *multipart.FileHeader)

func (*FileField) Validate Uses

func (f *FileField) Validate(rawValue interface{}) error

func (*FileField) Value Uses

func (f *FileField) Value() *multipart.FileHeader

type FileWidget Uses

type FileWidget struct {
    *BaseWidget
}

func NewFileWidget Uses

func NewFileWidget() *FileWidget

func (*FileWidget) Render Uses

func (w *FileWidget) Render(attrs []string, values ...string) template.HTML

type Form Uses

type Form interface {
    SetFields(map[string]Field)
    Fields() map[string]Field

    SetErrors(map[string]error)
    Errors() map[string]error
}

type HiddenWidget Uses

type HiddenWidget struct {
    *BaseWidget
}

func NewHiddenWidget Uses

func NewHiddenWidget() *HiddenWidget

func (*HiddenWidget) IsHidden Uses

func (w *HiddenWidget) IsHidden() bool

func (*HiddenWidget) Render Uses

func (w *HiddenWidget) Render(attrs []string, values ...string) template.HTML

type Int64Choice Uses

type Int64Choice struct {
    Value int64
    Label string
}

type Int64ChoiceField Uses

type Int64ChoiceField struct {
    *Int64Field
}

func NewRadioInt64Field Uses

func NewRadioInt64Field() *Int64ChoiceField

func NewSelectInt64Field Uses

func NewSelectInt64Field() *Int64ChoiceField

func (*Int64ChoiceField) SetChoices Uses

func (f *Int64ChoiceField) SetChoices(choices []Int64Choice)

type Int64ChoicesValidator Uses

type Int64ChoicesValidator struct {
    Choices []Int64Choice
}

func NewInt64ChoicesValidator Uses

func NewInt64ChoicesValidator(choices []Int64Choice) *Int64ChoicesValidator

func (*Int64ChoicesValidator) Validate Uses

func (v *Int64ChoicesValidator) Validate(rawValue interface{}) error

type Int64Field Uses

type Int64Field struct {
    *BaseField
}

func NewInt64Field Uses

func NewInt64Field() *Int64Field

func (*Int64Field) Render Uses

func (f *Int64Field) Render(attrs ...string) template.HTML

func (*Int64Field) SetInitial Uses

func (f *Int64Field) SetInitial(initial int64)

func (*Int64Field) Validate Uses

func (f *Int64Field) Validate(rawValue interface{}) error

func (*Int64Field) Value Uses

func (f *Int64Field) Value() int64

type MultiInt64ChoiceField Uses

type MultiInt64ChoiceField struct {
    *Int64ChoiceField
}

func NewMultiSelectInt64Field Uses

func NewMultiSelectInt64Field() *MultiInt64ChoiceField

func (*MultiInt64ChoiceField) Render Uses

func (f *MultiInt64ChoiceField) Render(attrs ...string) template.HTML

func (*MultiInt64ChoiceField) SetInitial Uses

func (f *MultiInt64ChoiceField) SetInitial(initial []int64)

func (*MultiInt64ChoiceField) StringValue Uses

func (f *MultiInt64ChoiceField) StringValue() []string

func (*MultiInt64ChoiceField) Validate Uses

func (f *MultiInt64ChoiceField) Validate(rawValue interface{}) error

func (*MultiInt64ChoiceField) Value Uses

func (f *MultiInt64ChoiceField) Value() []int64

type MultiStringChoiceField Uses

type MultiStringChoiceField struct {
    *StringChoiceField
}

func NewMultiSelectStringField Uses

func NewMultiSelectStringField() *MultiStringChoiceField

func (*MultiStringChoiceField) Render Uses

func (f *MultiStringChoiceField) Render(attrs ...string) template.HTML

func (*MultiStringChoiceField) SetInitial Uses

func (f *MultiStringChoiceField) SetInitial(initial []string)

func (*MultiStringChoiceField) StringValue Uses

func (f *MultiStringChoiceField) StringValue() []string

func (*MultiStringChoiceField) Validate Uses

func (f *MultiStringChoiceField) Validate(rawValue interface{}) error

func (*MultiStringChoiceField) Value Uses

func (f *MultiStringChoiceField) Value() []string

type MultiValueField Uses

type MultiValueField interface {
    StringValue() []string
}

type RadioWidget Uses

type RadioWidget struct {
    *BaseWidget
    // contains filtered or unexported fields
}

func NewRadioWidget Uses

func NewRadioWidget() *RadioWidget

func (*RadioWidget) Radios Uses

func (w *RadioWidget) Radios(attrs []string, checkedValue string) []template.HTML

func (*RadioWidget) Render Uses

func (w *RadioWidget) Render(attrs []string, checkedValues ...string) template.HTML

func (*RadioWidget) SetChoices Uses

func (w *RadioWidget) SetChoices(choices [][2]string)

type SelectWidget Uses

type SelectWidget struct {
    *BaseWidget
    // contains filtered or unexported fields
}

func NewMultiSelectWidget Uses

func NewMultiSelectWidget() *SelectWidget

func NewSelectWidget Uses

func NewSelectWidget() *SelectWidget

func (*SelectWidget) Options Uses

func (w *SelectWidget) Options(selValues ...string) []string

func (*SelectWidget) Render Uses

func (w *SelectWidget) Render(attrs []string, values ...string) template.HTML

func (*SelectWidget) SetChoices Uses

func (w *SelectWidget) SetChoices(choices [][2]string)

type SingleValueField Uses

type SingleValueField interface {
    StringValue() string
}

type StringChoice Uses

type StringChoice struct {
    Value string
    Label string
}

type StringChoiceField Uses

type StringChoiceField struct {
    *StringField
}

func NewRadioStringField Uses

func NewRadioStringField() *StringChoiceField

func NewSelectStringField Uses

func NewSelectStringField() *StringChoiceField

func (*StringChoiceField) SetChoices Uses

func (f *StringChoiceField) SetChoices(choices []StringChoice)

type StringChoicesValidator Uses

type StringChoicesValidator struct {
    Choices []StringChoice
}

func NewStringChoicesValidator Uses

func NewStringChoicesValidator(choices []StringChoice) *StringChoicesValidator

func (*StringChoicesValidator) Validate Uses

func (v *StringChoicesValidator) Validate(rawValue interface{}) error

type StringField Uses

type StringField struct {
    *BaseField
    MinLen, MaxLen int
}

func NewStringField Uses

func NewStringField() *StringField

func (*StringField) Render Uses

func (f *StringField) Render(attrs ...string) template.HTML

func (*StringField) SetInitial Uses

func (f *StringField) SetInitial(initial string)

func (*StringField) Validate Uses

func (f *StringField) Validate(rawValue interface{}) error

func (*StringField) Value Uses

func (f *StringField) Value() string

type TextWidget Uses

type TextWidget struct {
    *BaseWidget
}

func NewTextWidget Uses

func NewTextWidget() *TextWidget

type TextareaStringField Uses

type TextareaStringField struct {
    *StringField
}

func NewTextareaStringField Uses

func NewTextareaStringField() *TextareaStringField

type TextareaWidget Uses

type TextareaWidget struct {
    *BaseWidget
}

func NewTextareaWidget Uses

func NewTextareaWidget() *TextareaWidget

type Validator Uses

type Validator interface {
    Validate(interface{}) error
}

type Widget Uses

type Widget interface {
    IsHidden() bool
    Attrs() *WidgetAttrs
    Render([]string, ...string) template.HTML
}

type WidgetAttrs Uses

type WidgetAttrs struct {
    // contains filtered or unexported fields
}

func (*WidgetAttrs) Clone Uses

func (w *WidgetAttrs) Clone() *WidgetAttrs

func (*WidgetAttrs) FromSlice Uses

func (w *WidgetAttrs) FromSlice(attrs []string)

func (*WidgetAttrs) Get Uses

func (w *WidgetAttrs) Get(name string) (string, bool)

func (*WidgetAttrs) Names Uses

func (w *WidgetAttrs) Names() []string

func (*WidgetAttrs) Pop Uses

func (w *WidgetAttrs) Pop(name string) (string, bool)

func (*WidgetAttrs) Set Uses

func (w *WidgetAttrs) Set(name, value string)

func (*WidgetAttrs) String Uses

func (w *WidgetAttrs) String() string

Directories

PathSynopsis
gorilla
gorilla/csrf

Package gforms imports 13 packages (graph). Updated 2016-07-29. Refresh now. Tools for package owners.