Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Delegate ¶
type Delegate interface { GetAccessCheck(r *http.Request) page.AccessChecker LoadData(r *http.Request) (interface{}, error) Submit(w http.ResponseWriter, r *http.Request, v interface{}) FormSubmitResult }
Delegate is a helper type that contains the form presentation and logic.
type ErrInvalidFormContentType ¶
type ErrInvalidFormContentType string
ErrInvalidFormContentType is an error that happens when a form submission happens with an incorrect content type.
func (ErrInvalidFormContentType) Error ¶
func (e ErrInvalidFormContentType) Error() string
type Form ¶
type Form struct {
// contains filtered or unexported fields
}
Form has handlers for a standard HTML form.
func NewForm ¶
NewForm creates a new instance of Form.
The key-value store will hold the form tokens. The page template is the surrounding page which will embed the form.
func (*Form) Page ¶
func (f *Form) Page(w http.ResponseWriter, r *http.Request)
Page is the main page that shows the form.
type FormPageData ¶
FormPageData represents the form state.
The Data attribute has the custom data that is either posted or loaded.
func (*FormPageData) CSRFToken ¶
func (f *FormPageData) CSRFToken() template.HTML
func (*FormPageData) ErrorMessages ¶
func (f *FormPageData) ErrorMessages() template.HTML
type FormSubmitResult ¶
type FormSubmitResult interface { // Do is the action, returning whether the form is needed to be rebuilt // or not. Do(w http.ResponseWriter, r *http.Request, fd *FormPageData) bool }
FormSubmitResult represents what should happen after a form submit.
func Error ¶
func Error(message string, err error) FormSubmitResult
Error tells a form that an error happened during the form submission.
func Redirect ¶
func Redirect(path string) FormSubmitResult
Redirect tells a form to redirect after submit.