Documentation
¶
Index ¶
- Constants
- type Element
- type ElementInterface
- type Field
- func (f *Field) AddError(err error)
- func (f *Field) Clear()
- func (f *Field) Errors() []FormError
- func (f *Field) Field() ElementInterface
- func (f *Field) GetName() string
- func (f *Field) HasError() bool
- func (f *Field) HasLabel() bool
- func (f *Field) IsFile() bool
- func (f *Field) Label() ElementInterface
- func (f *Field) SetDisabled(disabled bool)
- func (f *Field) SetFile(filename string, file io.ReadCloser) error
- func (f *Field) SetHidden(hidden bool)
- func (f *Field) SetReadOnly(readOnly bool)
- func (f *Field) SetRequired(required bool)
- func (f *Field) SetValue(value string)
- func (f *Field) String() string
- func (f *Field) Validate() error
- func (f *Field) Value() *FormData
- type Form
- func (f *Form) AddError(name string, err error)
- func (f *Form) AddFields(field ...FormElement)
- func (f Form) AsP() template.HTML
- func (f *Form) Clear()
- func (f *Form) Disabled(names ...string) Form
- func (f *Form) Field(name string) FormElement
- func (f *Form) Fill(r *request.Request) bool
- func (f *Form) Get(name string) *FormData
- func (f *Form) Validate() bool
- func (f *Form) Without(names ...string)
- type FormData
- type FormElement
- type FormError
- type FormErrors
- type FormValue
- type Option
Constants ¶
View Source
const ( TypeText = "text" TypePassword = "password" TypeEmail = "email" TypeNumber = "number" TypeRange = "range" TypeTextArea = "textarea" TypeCheck = "checkbox" TypeRadio = "radio" TypeSelect = "select" TypeHidden = "hidden" TypeFile = "file" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ElementInterface ¶ added in v1.0.6
type Field ¶
type Field struct {
LabelText string
LabelClass string
ID string
Class string
Placeholder string
Type string
Name string
FormValue *FormData
Max int
Min int
Required bool
Disabled bool
Options []*Option
Autocomplete string
// FORMAT: "%s is required"
ErrorMessageFieldRequired string
// FORMAT: "%s is too long"
ErrorMessageFieldMax string
// FORMAT: "%s is too short"
ErrorMessageFieldMin string
// FORMAT: "%s is not a valid number (%s)"
ErrorMessageNaN string
Validators []validators.Validator
FormErrors FormErrors
// Render function
RenderLabel func(f *Field) Element
Render func(f *Field) Element
}
func (*Field) Field ¶
func (f *Field) Field() ElementInterface
func (*Field) Label ¶
func (f *Field) Label() ElementInterface
func (*Field) SetDisabled ¶ added in v1.0.6
func (*Field) SetFile ¶ added in v1.0.6
func (f *Field) SetFile(filename string, file io.ReadCloser) error
func (*Field) SetReadOnly ¶ added in v1.0.6
func (*Field) SetRequired ¶ added in v1.0.6
type Form ¶
type Form struct {
Fields []FormElement
Errors FormErrors
BeforeValid func(*request.Request, *Form) error
AfterValid func(*request.Request, *Form) error
}
func (*Form) AddFields ¶
func (f *Form) AddFields(field ...FormElement)
AddField adds a field to the form
func (*Form) Field ¶
func (f *Form) Field(name string) FormElement
type FormData ¶ added in v1.0.6
type FormData struct {
Val string
FileName string
Reader io.ReadCloser
}
type FormElement ¶ added in v1.0.6
type FormElement interface {
// Get the name of the field.
GetName() string
// Whether the field has a label.
HasLabel() bool
// Get the label for the field.
Label() ElementInterface
// Get the field element.
Field() ElementInterface
// Get, set or clear the value of the field.
SetValue(string)
SetFile(filename string, file io.ReadCloser) error
Value() *FormData
Clear()
// Validate the field.
Validate() error
// Errors
Errors() []FormError
AddError(error)
HasError() bool
// Relevant attributes to set.
SetReadOnly(bool)
SetDisabled(bool)
SetRequired(bool)
SetHidden(bool)
IsFile() bool
}
type FormErrors ¶
type FormErrors []FormError
func (*FormErrors) Add ¶
func (f *FormErrors) Add(name string, err error)
func (FormErrors) AsP ¶
func (f FormErrors) AsP() template.HTML
func (FormErrors) AsUL ¶
func (f FormErrors) AsUL() template.HTML
func (FormErrors) Error ¶
func (f FormErrors) Error() string
func (FormErrors) HasErrors ¶
func (f FormErrors) HasErrors() bool
func (FormErrors) String ¶
func (f FormErrors) String() string
Click to show internal directories.
Click to hide internal directories.