htmlinputs

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 5 Imported by: 0

README

struct-html-inputs

See the tests for an example.

Documentation

Index

Constants

View Source
const (
	TypeText     = 1
	TypeTextarea = 2
	TypePassword = 3
	TypeEmail    = 4
)
View Source
const (
	DefaultTagName = "html"
)

Variables

This section is empty.

Functions

func Inputs

func Inputs(obj interface{}, options *Options) (map[string]string, []string)

Inputs take a struct and generate HTML inputs for each of the fields, e.g. <input> or <textarea>

Types

type Options

type Options struct {
	RestrictFields  map[string]struct{}
	ExcludeFields   map[string]struct{}
	TagName         string
	IDPrefix        string
	NamePrefix      string
	OverwriteValues map[string]string
	Values          bool
}

Optional configuration for validation: * RestrictFields defines what struct fields should be generated * ExcludeFields defines what struct fields should be excluded from generation * TagName sets tag used to define validation (default is "html") * IDPrefix - if added, an element will contain an 'id' attribute in form of prefix + field name * NamePrefix - use this to put a prefix in the 'name' attribute * OverwriteValues - fill inputs with the specified values * Values - when true then fill inputs with struct instance values

Jump to

Keyboard shortcuts

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