form

package
v0.0.0-...-99ae320 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2015 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValidFormData

func GetValidFormData(w *wrapper.Wrapper, post interface{}) error

Types

type Field

type Field struct {
	Type            string           `json:"type" bson:"type"`
	Hide            bool             `json:"hide,omitempty" bson:"hide,omitempty"`
	Key             string           `json:"key" bson:"key"`
	TemplateOptions *TemplateOptions `json:"templateOptions" bson:"templateOptions"`
	HideExpression  string           `json:"hideExpression,omitempty" bson:"hideExpression"`
	Validator       string           `json:"-" bson:"validator,omitempty"`
}

Form fields structure

func (*Field) AddHideExpression

func (f *Field) AddHideExpression(he string) *Field

func (*Field) AddLabel

func (f *Field) AddLabel(l string) *Field

Add label to field

func (*Field) AddPlaceHolder

func (f *Field) AddPlaceHolder(p string) *Field

Add

func (*Field) AddRowsCols

func (f *Field) AddRowsCols(r int, c int) *Field

func (*Field) Hidden

func (f *Field) Hidden() *Field

func (*Field) Required

func (f *Field) Required() *Field

type Form

type Form struct {
	Fields   []*Field      `json:"formFields"`
	FormData interface{}   `json:"formData"`
	FormId   bson.ObjectId `json:"formId"`
}

Basic form structure, required by Formly

func NewForm

func NewForm() *Form

Constructor for form

func (*Form) AddCheckBox

func (f *Form) AddCheckBox(k string) *Field

Add a checkbox to form

func (*Form) AddRadio

func (f *Form) AddRadio(k string, o []map[string]string) *Field

Add a radio button to form

func (*Form) AddRepeatSection

func (f *Form) AddRepeatSection(k string, b string, fs []*Field) *Field

Add a radio button to form

func (*Form) AddSelect

func (f *Form) AddSelect(k string, o []map[string]string) *Field

Add a radio button to form

func (*Form) AddText

func (f *Form) AddText(k string, t string) *Field

Add a text field to form

func (*Form) AddTextArea

func (f *Form) AddTextArea(k string) *Field

Add a text are to form

func (*Form) Register

func (f *Form) Register(w *wrapper.Wrapper) error

Register the form in the database

type FormRegister

type FormRegister struct {
	FormFields []*Field      `bson:"fields"`
	FormId     bson.ObjectId `bson:"_id"`
	SessionId  bson.ObjectId `bson:"session_id"`
	Created    time.Time     `bson:"created"`
}

Structure for form registration

func GetFormRegister

func GetFormRegister(i string, w *wrapper.Wrapper) (*FormRegister, error)

Retrieve a previously registered form by id

func GetValidRegForm

func GetValidRegForm(i string, w *wrapper.Wrapper) (*FormRegister, error)

Retrieve valid form based on id and session id

func (*FormRegister) ValidateRequired

func (fr *FormRegister) ValidateRequired(data map[string]interface{}) map[string]string

Check for missing required fields.

type TemplateOptions

type TemplateOptions struct {
	Options     []map[string]string `json:"options,omitempty" bson:"options,omitempty"`
	Label       string              `json:"label,omitempty" bson:"label"`
	Required    bool                `json:"required,omitempty" bson:"required"`
	Placeholder string              `json:"placeholder,omitempty" bson:"placeholder,omitempty"`
	Rows        int                 `json:"rows,omitempty" bson:"rows,omitempty"`
	Cols        int                 `json:"cols,omitempty" bson:"cols,omitempty"`
	Fields      []*Field            `json:"fields,omitempty" bson:"fields,omitempty"`
	ButtonText  string              `json:"btnText,omitempty" bson:"btnText,omitempty"`
}

Jump to

Keyboard shortcuts

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