xmpp: mellium.im/xmpp/form Index | Files

package form

import "mellium.im/xmpp/form"

Package form is an implementation of XEP-0004: Data Forms.

BE ADVISED: This API is unstable and subject to change.

Index

Package Files

doc.go fields.go form.go options.go

Constants

const NS = "jabber:x:data"

NS is the data forms namespace.

type Data Uses

type Data struct {
    // contains filtered or unexported fields
}

Data represents a data form.

func New Uses

func New(o ...Field) *Data

New builds a new data form from the provided options.

func (*Data) MarshalXML Uses

func (d *Data) MarshalXML(e *xml.Encoder, start xml.StartElement) (err error)

MarshalXML satisfies the xml.Marshaler interface for *Data.

type Field Uses

type Field func(*Data)

An Field is used to define the behavior and appearance of a data form.

func Boolean Uses

func Boolean(id string, o ...Option) Field

Boolean fields enable an entity to gather or provide an either-or choice between two options.

func Fixed Uses

func Fixed(o ...Option) Field

Fixed is intended for data description (e.g., human-readable text such as "section" headers) rather than data gathering or provision.

func Hidden Uses

func Hidden(id string, o ...Option) Field

Hidden fields are not shown by the form-submitting entity, but instead are returned, generally unmodified, with the form.

func Instructions Uses

func Instructions(s string) Field

Instructions adds new textual instructions to the form. Multiple uses of the option result in multiple sets of instructions.

func JID Uses

func JID(id string, o ...Option) Field

JID enables an entity to gather or provide a Jabber ID.

func JIDMulti Uses

func JIDMulti(id string, o ...Option) Field

JIDMulti enables an entity to gather or provide multiple Jabber IDs.

func ListMulti Uses

func ListMulti(id string, o ...Option) Field

ListMulti enables an entity to gather or provide one or more entries from a list.

func ListSingle Uses

func ListSingle(id string, o ...Option) Field

ListSingle enables an entity to gather or provide a single entry from a list.

func TextMulti Uses

func TextMulti(id string, o ...Option) Field

TextMulti enables an entity to gather or provide multiple lines of text.

func TextPrivate Uses

func TextPrivate(id string, o ...Option) Field

TextPrivate enables an entity to gather or provide a line of text that should be obscured in the submitting entities interface (eg. with multiple asterisks).

func TextSingle Uses

func TextSingle(id string, o ...Option) Field

TextSingle enables an entity to gather or provide a line of text.

func Title Uses

func Title(s string) Field

Title sets a form's title.

type Option Uses

type Option func(*field)

A Option is used to define the behavior and appearance of a form field.

var (
    // Required flags the field as required in order for the form to be considered
    // valid.
    Required Option = required
)

func Desc Uses

func Desc(s string) Option

Desc provides a natural-language description of the field, intended for presentation in a user-agent (e.g., as a "tool-tip", help button, or explanatory text provided near the field). Desc should not contain newlines (the \n and \r characters), since layout is the responsibility of a user agent. However, it does nothing to prevent them from being added.

func ListField Uses

func ListField(s string) Option

ListField is one of the values in a list. It has no effect on any non-list field type.

func Value Uses

func Value(s string) Option

Value defines the default value for the field (according to the form-processing entity) in a data form of type "form", the data provided by a form-submitting entity in a data form of type "submit", or a data result in a data form of type "result". Fields of type ListMulti, JidMulti, TextMulti, and Hidden may contain more than one Value; all other field types will only use the first Value.

Package form imports 1 packages (graph) and is imported by 1 packages. Updated 2018-09-28. Refresh now. Tools for package owners.