Documentation ¶
Index ¶
- Variables
- func DefaultHandler(c *gin.Context, db *sqlx.DB, form Form)
- func FormSaveFullReload(c *gin.Context, f Form)
- type Form
- type FormBase
- func (f *FormBase[T]) AddError(fieldName string, message string)
- func (f *FormBase[T]) AddTemplateData(field string, value any)
- func (f *FormBase[T]) ClearInput()
- func (f *FormBase[T]) FormName() string
- func (f *FormBase[T]) RenderForm(c *gin.Context)
- func (f *FormBase[T]) Save(c context.Context, exec boil.ContextExecutor) (FormSaveAction, error)
- func (f *FormBase[T]) SetFormError(message string)
- func (f *FormBase[T]) ShouldBind(c *gin.Context) error
- func (f *FormBase[T]) TemplateData() map[string]interface{}
- type FormErrors
- type FormSaveAction
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrValidationFailed = errors.Errorf("Form validation failed")
Functions ¶
func FormSaveFullReload ¶
Types ¶
type Form ¶
type Form interface { FormName() string ClearInput() ShouldBind(c *gin.Context) error RenderForm(c *gin.Context) SetFormError(message string) AddError(fieldName string, message string) Save(c context.Context, exec boil.ContextExecutor) (FormSaveAction, error) AddTemplateData(field string, value any) TemplateData() map[string]interface{} // the only thing to implement in the child form Validate(c *gin.Context, exec boil.ContextExecutor) error }
type FormBase ¶
type FormBase[T any] struct { Name string FormTemplate string FormSaved bool KeepValuesAfterSave bool FullPageReloadOnSave bool // we make no effort to sync the keys names between // errors and struct, we just assume it to be matching. // Same goes for the templates - it's completely left // to the developer Errors FormErrors FormError string Input *T ExtraTemplateData map[string]interface{} }
func (*FormBase[T]) AddTemplateData ¶
func (*FormBase[T]) ClearInput ¶
func (f *FormBase[T]) ClearInput()
func (*FormBase[T]) RenderForm ¶
func (*FormBase[T]) Save ¶
func (f *FormBase[T]) Save(c context.Context, exec boil.ContextExecutor) (FormSaveAction, error)
func (*FormBase[T]) SetFormError ¶
func (*FormBase[T]) TemplateData ¶
type FormErrors ¶
func (FormErrors) HasError ¶
func (fe FormErrors) HasError(fieldName string) bool
func (FormErrors) PassedValidation ¶
func (fe FormErrors) PassedValidation() error
type FormSaveAction ¶
func FormSaveDefault ¶
func FormSaveDefault(keepValues bool) FormSaveAction
func FormSaveRedirect ¶
func FormSaveRedirect(url string) FormSaveAction
Click to show internal directories.
Click to hide internal directories.