form

package
v0.0.0-...-65ffb28 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element struct {
	// ID of the element.  Must be unique.
	ID string
	// Name of the element.  Used as key to retrieve the value on submission.
	Name string
	// The Label of the field as it appears on the rendered form.
	Label string
	// If set, the field will be filled with the given value, or the
	// appropriate option will be selected, when rendered.
	Value string
	// Whether the element represents a required form field.
	Required bool
	// An optional description for the field.  If set will be displayed under
	// the input field.  Can be used to provide extra information such as input
	// constraints.
	Description string
	// Type is the HTML input element type.
	Type ElementType
	// ValueList should contain a set of values that represent the permissible
	// or recommended options available to the element.  For input type
	// elements, it represents suggested values (datalist).  For select
	// elements, it represents the values in the list.
	ValueList []string
	// Read only fields can't be edited.
	ReadOnly bool
}

Element represents a single form element (field).

func (*Element) HTML

func (e *Element) HTML(ro bool) template.HTML

HTML returns the HTML representation of this element.

type ElementType

type ElementType string

ElementType defines the type of a form input element: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input

const (
	// CheckboxInput is a fieldset that groups a number of "checkbox" inputs for the same variable.
	CheckboxInput ElementType = "checkbox"
	// ColorInput is an input element with type "color".
	ColorInput ElementType = "color"
	// DateInput is an input element with type "date"."
	DateInput ElementType = "date"
	// DateTimeInput is an input element with type "datetime-local".
	DateTimeInput ElementType = "datetime-local"
	// EmailInput is an input element with type "email".
	EmailInput ElementType = "email"
	// FileInput is an input element with type "file".
	FileInput ElementType = "file"
	// HiddenInput is an input element with type "hidden".
	HiddenInput ElementType = "hidden"
	// MonthInput is an input element with type "month".
	MonthInput ElementType = "month"
	// NumberInput is an input element with type "number".
	NumberInput ElementType = "number"
	// PasswordInput is an input element with type "password".
	PasswordInput ElementType = "password"
	// RadioInput is a fieldset that groups a number of "radio" inputs for the same variable.
	RadioInput ElementType = "radio"
	// RangeInput is an input element with type "range".
	RangeInput ElementType = "range"
	// SearchInput is an input element with type "search".
	SearchInput ElementType = "search"
	// TelInput is an input element with type "tel".
	TelInput ElementType = "tel"
	// TextInput is an input element with type "text".
	TextInput ElementType = "text"
	// TimeInput is an input element with type "time".
	TimeInput ElementType = "time"
	// URLInput is an input element with type "url".
	URLInput ElementType = "url"
	// WeekInput is an input element with type "week".
	WeekInput ElementType = "week"
	// TextArea is an "textarea" element.
	TextArea ElementType = "textarea"
	// Select is an input element with type "select".  Requires a ValueList.
	Select ElementType = "select"
)

type Form

type Form struct {
	// The Name appears at the top of all pages in the form and in the HTML
	// title.
	Name string
	// The Description appears under the Name on every page.
	Description string
	// Each Page creates a form page with the included elements.  The last page
	// contains the submit button.
	Pages []Page
}

Form is the top level type for defining the web form for user input.

type Page

type Page struct {
	// The Description appears under the form description.  Use it to provide
	// information about the elements of the specific page.
	Description string
	// Each element creates an input field on the form.
	Elements []Element
}

Page represents a single page of a multi-page web form.

Jump to

Keyboard shortcuts

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