forms

package
v0.0.0-...-e7b361f Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Package forms provides support for HTML forms and its input elements.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Form

type Form struct {

	// ValidationItems is a map of field names and their corresponding
	// validation.Item. Used to get information about the items’ validation
	// rules.
	ValidationItems validation.Items

	// ValidationMessages contains a validation error message for each form
	// field that has an invalid value.
	ValidationMessages validation.Messages
	// contains filtered or unexported fields
}

Form represents an HTML form.

func New

func New(request *http.Request) *Form

New returns a new instance of Form.

func (*Form) Checkbox

func (f *Form) Checkbox(fieldName, value string, attributes ...string) *elements.Element

Checkbox returns an <input type="checkbox"> element.

func (*Form) Email

func (f *Form) Email(fieldName, placeholder string) *elements.Element

Email returns an <input type="email"> element.

func (*Form) Error

func (f *Form) Error(fieldName string) *elements.Element

Error returns a <div class="validation-error"> element that contains the validation error message as text.

func (*Form) HasError

func (f *Form) HasError(fieldName string) bool

HasError returns whether the field’s value is invalid.

func (*Form) Input

func (f *Form) Input(fieldName, placeholder string, attributes ...string) *elements.Element

Input returns an <input> element.

func (*Form) Number

func (f *Form) Number(fieldName, placeholder string, attributes ...string) *elements.Element

Number returns an <input type="number"> element.

func (*Form) Option

func (f *Form) Option(value, label string) *elements.Element

Option returns an <option> element.

func (*Form) Password

func (f *Form) Password(fieldName, placeholder string, attributes ...string) *elements.Element

Password returns an <input type="password"> element.

func (*Form) Radio

func (f *Form) Radio(fieldName, value string) *elements.Element

Radio returns an <input type="radio"> element.

func (*Form) Search

func (f *Form) Search(fieldName, placeholder string, attributes ...string) *elements.Element

Search returns an <input type="search"> element.

func (*Form) Select

func (f *Form) Select(fieldName string, options []*Option) *elements.Element

Select returns a <select> element.

func (*Form) Text

func (f *Form) Text(fieldName, placeholder string, attributes ...string) *elements.Element

Text returns an <input type="text"> element.

func (*Form) Textarea

func (f *Form) Textarea(fieldName, placeholder string, attributes ...string) *elements.Element

Textarea returns a <textarea> element.

type Option

type Option struct {
	Label string
	Value string
}

Option can be passed to Form.Select to populate a <select> element with <option> elements.

type Options

type Options []*Option

func (Options) Len

func (o Options) Len() int

func (Options) Less

func (o Options) Less(i, j int) bool

func (Options) Swap

func (o Options) Swap(i, j int)

Jump to

Keyboard shortcuts

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