Documentation ¶
Index ¶
Constants ¶
View Source
const ( FormXSRF = "_xsrf" CookieXSRF = "_xsrf" )
Variables ¶
View Source
var ErrDuplicatedName = errors.New("duplicated form name")
Functions ¶
func XSRF ¶
func XSRF(writer http.ResponseWriter) string
XSRF protection token. Returned token should be submitted as _xsrf form value. Panics if crypto generator is not available.
Types ¶
type Config ¶
type Config struct { Forms []schema.Form Storage Storage Dispatcher WebhooksDispatcher Listing bool }
type Form ¶
type Form struct {
// contains filtered or unexported fields
}
func NewForm ¶
func NewForm(config FormConfig, options ...FormOption) *Form
type FormConfig ¶
type FormConfig struct { Definition schema.Form // schema definition Renderer *Renderer // renderer for template blocks ViewForm *template.Template // template to show main form ViewResult *template.Template // template to show result after submit Storage Storage // where to store data WebhooksDispatcher WebhooksDispatcher // how to execute webhooks XSRF bool // check XSRF token. Disable if form is exposed as API. }
type FormOption ¶
type FormOption func(config *FormConfig)
func WithXSRF ¶
func WithXSRF(enable bool) FormOption
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
type ResultContext ¶
type ViewContext ¶
func (*ViewContext) FieldError ¶
func (vc *ViewContext) FieldError(name string) error
func (*ViewContext) LastValue ¶
func (vc *ViewContext) LastValue(name string) string
func (*ViewContext) LastValues ¶
func (vc *ViewContext) LastValues(name string) utils.Set[string]
Click to show internal directories.
Click to hide internal directories.