formx

package
v0.0.0-...-baf4ea5 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package formx provides user-editable forms

Index

Constants

View Source
const (
	QuestionTypeParagraph  = "paragraph"
	QuestionTypeShorttext  = "short text"
	QuestionTypeLongtext   = "long text"
	QuestionTypeCheckbox   = "checkbox"
	QuestionTypeSelect     = "select"
	QuestionTypeRadio      = "radio"
	QuestionTypeMultiradio = "multiradio"
	QuestionTypeDate       = "date"
	QuestionTypeTime       = "time"
	QuestionTypeImage      = "image"
	QuestionTypeNull       = ""
)

Variables

This section is empty.

Functions

func CheckboxAnswers

func CheckboxAnswers(qna QuestionAnswer) string

func Funcs

func Funcs(funcs template.FuncMap, policy *bluemonday.Policy) template.FuncMap

func JoinSlice

func JoinSlice(slice []string) string

func MultiradioAnswers

func MultiradioAnswers(qna QuestionAnswer, subqna SubquestionAnswer) string

func RadioSelectAnswers

func RadioSelectAnswers(qna QuestionAnswer) string

func SanitizeHTML

func SanitizeHTML(policy *bluemonday.Policy) func(string) template.HTML

Types

type Answers

type Answers map[string][]string

func ExtractAnswers

func ExtractAnswers(form url.Values, questions []Question) (answers Answers)

func (Answers) IsEmpty

func (answers Answers) IsEmpty() bool

func (*Answers) Scan

func (answers *Answers) Scan(value interface{}) error

func (Answers) Value

func (answers Answers) Value() (driver.Value, error)

type Option

type Option struct {
	Value   string `json:"Value"`
	Display string `json:"Display"`
}

type Question

type Question struct {
	Type         string        `json:"Type"`
	Text         string        `json:"Text"`
	Name         string        `json:"Name"`
	Options      []Option      `json:"Options"`
	Subquestions []Subquestion `json:"Subquestions"`
}

func (*Question) Scan

func (question *Question) Scan(value interface{}) (err error)

func (Question) Value

func (question Question) Value() (driver.Value, error)

type QuestionAnswer

type QuestionAnswer struct {
	Type               string              `json:"Type"`
	Text               string              `json:"Text"`
	Name               string              `json:"Name"`
	Options            []Option            `json:"Options"`
	SubquestionAnswers []SubquestionAnswer `json:"SubquestionAnswers"`
	Answer             []string            `json:"Answer"`
}

func MergeQuestionsAnswers

func MergeQuestionsAnswers(questions Questions, answers Answers) []QuestionAnswer

type Questions

type Questions []Question

func (*Questions) Scan

func (questions *Questions) Scan(value interface{}) error

func (Questions) Value

func (questions Questions) Value() (driver.Value, error)

type Subquestion

type Subquestion struct {
	Name string `json:"Name"`
	Text string `json:"Text"`
}

type SubquestionAnswer

type SubquestionAnswer struct {
	Name   string `json:"Name"`
	Text   string `json:"Text"`
	Answer string `json:"Answer"`
}

Jump to

Keyboard shortcuts

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