fields

package
v1.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2023 License: BSD-1-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllTagsInput = []string{
	"class",
	"style",
	"placeholder",
	"rows",
	"cols",
	"selected",
	"multiple",
	"disabled",
	"readonly",
	"required",
	"autofocus",
	"autocomplete",
	"min",
	"max",
	"step",
}

excludes the name, selected, value, type

View Source
var AllTagsLabel = []string{
	"labelclass",
	"labelid",
	"labelstyle",
}

Functions

func NumberField

func NumberField(n any) interfaces.FormField

func TagMapToElementAttributes

func TagMapToElementAttributes(t tags.TagMap, fields ...string) string

Types

type BoolField

type BoolField bool

func (*BoolField) FormValues

func (i *BoolField) FormValues(v []string) error

func (BoolField) InputHTML

func (i BoolField) InputHTML(_ *request.Request, name string, tags tags.TagMap) interfaces.Element

func (BoolField) LabelHTML

func (i BoolField) LabelHTML(_ *request.Request, name string, display_text string, tags tags.TagMap) interfaces.Element

func (*BoolField) Scan

func (i *BoolField) Scan(src interface{}) error

func (BoolField) Value

func (i BoolField) Value() (driver.Value, error)

type CheckBoxField

type CheckBoxField []string

func (*CheckBoxField) FormValues

func (i *CheckBoxField) FormValues(v []string) error

func (CheckBoxField) InputHTML

func (i CheckBoxField) InputHTML(_ *request.Request, name string, tags tags.TagMap) interfaces.Element

func (CheckBoxField) LabelHTML

func (i CheckBoxField) LabelHTML(_ *request.Request, name string, display string, tags tags.TagMap) interfaces.Element

func (*CheckBoxField) Scan

func (i *CheckBoxField) Scan(src interface{}) error

func (CheckBoxField) Value

func (i CheckBoxField) Value() (driver.Value, error)

type DateField

type DateField time.Time

func (*DateField) FormValues

func (i *DateField) FormValues(v []string) error

func (DateField) InputHTML

func (i DateField) InputHTML(_ *request.Request, name string, tags tags.TagMap) interfaces.Element

func (DateField) LabelHTML

func (i DateField) LabelHTML(_ *request.Request, name string, display_text string, tags tags.TagMap) interfaces.Element

func (*DateField) Scan

func (i *DateField) Scan(src interface{}) error

func (DateField) Value

func (i DateField) Value() (driver.Value, error)

type DateTimeField

type DateTimeField time.Time

func (*DateTimeField) FormValues

func (i *DateTimeField) FormValues(v []string) error

func (DateTimeField) InputHTML

func (i DateTimeField) InputHTML(_ *request.Request, name string, tags tags.TagMap) interfaces.Element

func (DateTimeField) LabelHTML

func (i DateTimeField) LabelHTML(_ *request.Request, name string, display_text string, tags tags.TagMap) interfaces.Element

func (*DateTimeField) Scan

func (i *DateTimeField) Scan(src interface{}) error

func (DateTimeField) Value

func (i DateTimeField) Value() (driver.Value, error)

type DoubleMultipleSelectField

type DoubleMultipleSelectField struct {
	Left  []interfaces.Option `json:"left"` // Left values will be stored on the database!
	Right []interfaces.Option `json:"-"`    // Right will not be stored in the database!
}

When using this field with the forms, you should fill the right and left values.

The left values will be stored on the database, and the values on the right will not be stored.

func (*DoubleMultipleSelectField) FormValues

func (i *DoubleMultipleSelectField) FormValues(v []string) error

func (*DoubleMultipleSelectField) Initial

func (i *DoubleMultipleSelectField) Initial(r *request.Request, model any, fieldName string)

func (DoubleMultipleSelectField) InputHTML

func (DoubleMultipleSelectField) LabelHTML

func (i DoubleMultipleSelectField) LabelHTML(_ *request.Request, name string, display_text string, tags tags.TagMap) interfaces.Element

func (*DoubleMultipleSelectField) Scan

func (i *DoubleMultipleSelectField) Scan(src interface{}) error

func (DoubleMultipleSelectField) Value

func (DoubleMultipleSelectField) Values

func (i DoubleMultipleSelectField) Values() []string

type ElementType

type ElementType string

func (ElementType) HTML

func (e ElementType) HTML() template.HTML

func (ElementType) String

func (e ElementType) String() string

type FileField

type FileField struct {
	Path string          `json:"path"`
	URL  string          `json:"url"`
	File interfaces.File `json:"-"`
}

Easily create files inside of forms.

FileField will save as JSON inside a database.

func (*FileField) FormFiles

func (i *FileField) FormFiles(files []interfaces.File) error

func (FileField) InputHTML

func (i FileField) InputHTML(r *request.Request, form_name string, tags tags.TagMap) interfaces.Element

func (FileField) LabelHTML

func (i FileField) LabelHTML(r *request.Request, form_name, display_text string, tags tags.TagMap) interfaces.Element

func (FileField) ListDisplay

func (i FileField) ListDisplay() string

func (*FileField) Save

func (i *FileField) Save(filer fs.Filer, media_url, pathInFiler string) error

Save the file to the filer.

This will also set the Path and URL fields.

func (*FileField) Scan

func (i *FileField) Scan(value interface{}) error

func (FileField) String

func (i FileField) String() string

func (FileField) Value

func (i FileField) Value() (driver.Value, error)

type FloatField

type FloatField float64

func (*FloatField) FormValues

func (i *FloatField) FormValues(v []string) error

func (FloatField) InputHTML

func (i FloatField) InputHTML(_ *request.Request, name string, tags tags.TagMap) interfaces.Element

func (FloatField) LabelHTML

func (i FloatField) LabelHTML(_ *request.Request, name string, display_text string, tags tags.TagMap) interfaces.Element

func (*FloatField) Scan

func (i *FloatField) Scan(src interface{}) error

func (FloatField) Value

func (i FloatField) Value() (driver.Value, error)

type FormFile

type FormFile struct {
	Filename string
	OpenFunc func() (io.ReadSeekCloser, error)
}

func (FormFile) Name

func (f FormFile) Name() string

func (FormFile) Open

func (f FormFile) Open() (io.ReadSeekCloser, error)

type IntField

type IntField int64

func (*IntField) FormValues

func (i *IntField) FormValues(v []string) error

func (IntField) InputHTML

func (i IntField) InputHTML(_ *request.Request, name string, tags tags.TagMap) interfaces.Element

func (IntField) LabelHTML

func (i IntField) LabelHTML(_ *request.Request, name string, display_text string, tags tags.TagMap) interfaces.Element

func (*IntField) Scan

func (i *IntField) Scan(src interface{}) error

func (IntField) Value

func (i IntField) Value() (driver.Value, error)

type MultipleSelectField

type MultipleSelectField []string

func (*MultipleSelectField) FormValues

func (i *MultipleSelectField) FormValues(v []string) error

func (*MultipleSelectField) Initial

func (i *MultipleSelectField) Initial(r *request.Request, model any, fieldName string)

func (MultipleSelectField) InputHTML

func (i MultipleSelectField) InputHTML(_ *request.Request, name string, tags tags.TagMap) interfaces.Element

func (MultipleSelectField) LabelHTML

func (i MultipleSelectField) LabelHTML(_ *request.Request, name string, display_text string, tags tags.TagMap) interfaces.Element

func (*MultipleSelectField) Scan

func (i *MultipleSelectField) Scan(src interface{}) error

func (MultipleSelectField) Value

func (i MultipleSelectField) Value() (driver.Value, error)

type Option

type Option struct {
	Val  string `json:"value"`
	Text string `json:"text"`
}

func AutoOption

func AutoOption(v any) Option

func (Option) Label

func (o Option) Label() string

func (Option) MarshalJSON

func (o Option) MarshalJSON() ([]byte, error)

func (*Option) UnmarshalJSON

func (o *Option) UnmarshalJSON(b []byte) error

func (Option) Value

func (o Option) Value() string

type SelectField

type SelectField []string

func (*SelectField) FormValues

func (i *SelectField) FormValues(v []string) error

func (*SelectField) Initial

func (i *SelectField) Initial(r *request.Request, model any, fieldName string)

func (SelectField) InputHTML

func (i SelectField) InputHTML(_ *request.Request, name string, tags tags.TagMap) interfaces.Element

func (SelectField) LabelHTML

func (i SelectField) LabelHTML(_ *request.Request, name string, display_text string, tags tags.TagMap) interfaces.Element

func (*SelectField) Scan

func (i *SelectField) Scan(src interface{}) error

func (SelectField) Value

func (i SelectField) Value() (driver.Value, error)

type SliceField

type SliceField[T any] []T

func (*SliceField[T]) FormValues

func (i *SliceField[T]) FormValues(v []string) error

func (*SliceField[T]) Initial

func (i *SliceField[T]) Initial(r *request.Request, model any, fieldName string)

func (SliceField[T]) InputHTML

func (i SliceField[T]) InputHTML(_ *request.Request, name string, tags tags.TagMap) interfaces.Element

func (SliceField[T]) LabelHTML

func (i SliceField[T]) LabelHTML(_ *request.Request, name string, tags tags.TagMap) interfaces.Element

func (*SliceField[T]) Scan

func (i *SliceField[T]) Scan(src interface{}) error

func (SliceField[T]) Value

func (i SliceField[T]) Value() (driver.Value, error)

type StringField

type StringField string

func (*StringField) FormValues

func (i *StringField) FormValues(v []string) error

func (StringField) InputHTML

func (i StringField) InputHTML(_ *request.Request, name string, tags tags.TagMap) interfaces.Element

func (StringField) LabelHTML

func (i StringField) LabelHTML(_ *request.Request, name string, display_text string, tags tags.TagMap) interfaces.Element

func (*StringField) Scan

func (i *StringField) Scan(src interface{}) error

func (StringField) Value

func (i StringField) Value() (driver.Value, error)

type TextField

type TextField string

func (*TextField) FormValues

func (i *TextField) FormValues(v []string) error

func (TextField) InputHTML

func (i TextField) InputHTML(_ *request.Request, name string, tags tags.TagMap) interfaces.Element

func (TextField) LabelHTML

func (i TextField) LabelHTML(_ *request.Request, name string, display_text string, tags tags.TagMap) interfaces.Element

func (*TextField) Scan

func (i *TextField) Scan(src interface{}) error

func (TextField) Value

func (i TextField) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL