form

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

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