golazy.dev
–
golazy.dev
/
lazyforms
Index
|
Files
package lazyforms
import "golazy.dev/lazyforms"
Functions
func Helpers
func Helpers(router Router) map[string]any
Types
type Field
type Field struct {
Form *Form
GoPath string
Path lazyschema.Path
Name string
ID string
Label string
Type string
Value any
Attrs map[string]string
Placeholder string
}
type FieldOption
type FieldOption func(*fieldOptions)
func FieldAttr
func FieldAttr(name string, value any) FieldOption
func FieldClass
func FieldClass(class string) FieldOption
func FieldData
func FieldData(name string, value any) FieldOption
func FieldID
func FieldID(id string) FieldOption
func FieldLabel
func FieldLabel(label string) FieldOption
func FieldPlaceholder
func FieldPlaceholder(value string) FieldOption
func FieldType
func FieldType(inputType string) FieldOption
func FieldValue
func FieldValue(value any) FieldOption
type Form
type Form struct {
Model any
ModelType reflect.Type
ModelKey string
Action string
Method string
HTMLMethod string
ID string
Class string
Partial string
Multipart bool
Attrs map[string]string
Data map[string]string
Fields []Field
OriginalDot any
}
func (f *Form) Field
func (f *Form) Field(fieldName string, options fieldOptions) (Field, error)
type NumericID
type NumericID interface {
ID() int
}
type Option
type Option func(*formOptions)
func FormAction
func FormAction(action string) Option
func FormAddClass
func FormAddClass(class string) Option
func FormAttr
func FormAttr(name string, value any) Option
func FormClass
func FormClass(class string) Option
func FormData
func FormData(name string, value any) Option
func FormFile
func FormFile(partial string) Option
func FormID
func FormID(id string) Option
func FormMethod
func FormMethod(method string) Option
func FormModel
func FormModel(modelName string) Option
func FormMultipart
func FormMultipart() Option
func FormRoute
func FormRoute(name string, values ...any) Option
func FormScope
func FormScope(scope string) Option
type Resource
type Resource interface {
Persisted() bool
RouteParam() string
}
type Router
type Router interface {
PathForModel(model any, action string) (string, error)
}
type StringID
type StringID interface {
ID() string
}
Package lazyforms provides model-aware form helpers for GoLazy views.
lazyapp installs these helpers automatically with the application's router so templates can build fields and form paths from route metadata. Applications that assemble lazyview directly can install the helpers with:
The package uses lazyschema for field names and ids so form generation and controller Decode calls stay aligned.