form

package
v0.3.2 Latest Latest
Warning

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

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

Documentation

Overview

Package form provides constructors and methods for the HTML <form> element.

The <form> HTML element represents a document section containing interactive controls for submitting user data to a server. Defines how and where form data should be sent, including HTTP method, action URL, encoding type, and validation behaviour. Central to user input collection, authentication, search, data entry, and any interaction requiring server communication.

Index

Constants

This section is empty.

Variables

View Source
var (
	TagOpen  = []byte("<form")
	TagClose = []byte("</form>")

	AttrAction         = []byte(" action=\"")
	AttrMethod         = []byte(" method=\"")
	AttrAcceptCharset  = []byte(" accept-charset=\"")
	AttrAutoCapitalize = []byte(" autocapitalize=\"")
	AttrAutoComplete   = []byte(" autocomplete=\"")
	AttrEncType        = []byte(" enctype=\"")
	AttrName           = []byte(" name=\"")
	AttrNoValidate     = []byte(" novalidate")
	AttrRel            = []byte(" rel=\"")
	AttrTarget         = []byte(" target=\"")
)

Byte constants for HTML rendering.

Functions

func Dialog added in v0.3.0

func Dialog(nodes ...node.Node) *element

Dialog creates a form with method="dialog" that closes the nearest ancestor dialog element when submitted. The form's return value is set to the value of the submit button used. Example: form.Dialog(button.Submit("Confirm"), button.Button("Cancel")) Renders: <form method="dialog"><button type="submit">Confirm</button><button type="button">Cancel</button></form>

func Get

func Get(action string, nodes ...node.Node) *element

Get creates a form with GET method and specified action URL. Use for search forms and other idempotent queries where the data appears in the URL. Example: form.Get("/search", input.Text("q", "")) Renders: <form action="/search" method="get"><input name="q" type="text" /></form>

func New

func New(nodes ...node.Node) *element

New creates a new form element with child nodes. Example: form.New(input.Text("name", ""), button.Submit("Send")) Renders: <form><input name="name" type="text" /><button type="submit">Send</button></form>

func Post

func Post(action string, nodes ...node.Node) *element

Post creates a form with POST method and specified action URL. Use for forms that modify data on the server (login, registration, creating records). Example: form.Post("/login", input.Email("email"), input.Password("password")) Renders: <form action="/login" method="post"><input name="email" type="email" /><input name="password" type="password" /></form>

Types

type Element

type Element = element

Element is an exported alias for the private element type

Jump to

Keyboard shortcuts

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