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 ¶
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
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 ¶
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 ¶
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 ¶
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>