Documentation
¶
Index ¶
- func GetTagOptions(fieldTag string) ([]fmt.KeyValue, bool)
- func ParseOptionsTag(tag string) []fmt.KeyValue
- func RegisterInput(inputs ...input.Input)
- func RenderCSS() *css.Stylesheet
- func SetGlobalClass(classes ...string)
- type Form
- func (f *Form) Children() []dom.Component
- func (f *Form) GetID() string
- func (f *Form) HideSubmit() *Form
- func (f *Form) Input(fieldName string) input.Input
- func (f *Form) NoResetOnSuccess() *Form
- func (f *Form) OnSubmit(fn func(fmt.Fielder, func(error))) *Form
- func (f *Form) ParentID() string
- func (f *Form) Reset()
- func (f *Form) SetID(id string)
- func (f *Form) SetOptions(fieldName string, opts ...fmt.KeyValue) *Form
- func (f *Form) SetSSR(enabled bool) *Form
- func (f *Form) SetValues(fieldName string, values ...string) *Form
- func (f *Form) String() string
- func (f *Form) SubmitLabel(text string) *Form
- func (f *Form) SubmitLoadingLabel(text string) *Form
- func (f *Form) SyncValues(data fmt.Fielder) error
- func (f *Form) Validate() error
- func (f *Form) ValidateData(action byte, data fmt.Fielder) error
- type Namer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTagOptions ¶ added in v0.0.2
GetTagOptions extracts options from a struct field tag using fmt.TagPairs.
func ParseOptionsTag ¶ added in v0.0.2
ParseOptionsTag parses "key1:text1,key2:text2" format into []fmt.KeyValue.
func RegisterInput ¶ added in v0.0.2
RegisterInput registers input types for field mapping.
func RenderCSS ¶ added in v0.2.4
func RenderCSS() *css.Stylesheet
RenderCSS returns the form's CSS contribution (additive — see tinywasm/css contract). Call from the project's css.go aggregate so assetmin picks it up.
func SetGlobalClass ¶ added in v0.0.2
func SetGlobalClass(classes ...string)
Types ¶
type Form ¶
Form represents a form instance.
func New ¶
New creates a new Form from a Fielder. parentID: ID of the parent DOM element where the form will be mounted. Returns an error if any exported field has no matching registered input.
func (*Form) Children ¶ added in v0.2.1
Children returns the form's input fields as dom components (O(1), zero-alloc).
func (*Form) HideSubmit ¶ added in v0.2.3
HideSubmit disables rendering of the submit button. Use this when the form is part of a larger UI that provides its own submit control (e.g. an external toolbar). Default is to render one.
func (*Form) Input ¶ added in v0.0.2
Input returns the input with the given field name, or nil if not found.
func (*Form) NoResetOnSuccess ¶ added in v0.2.4
NoResetOnSuccess disables the automatic form reset after a successful submit.
func (*Form) OnSubmit ¶ added in v0.0.2
OnSubmit sets the callback for form submission in WASM mode.
func (*Form) Reset ¶ added in v0.2.4
func (f *Form) Reset()
Reset clears all input values and error messages in the DOM and internal state.
func (*Form) SetOptions ¶ added in v0.0.2
SetOptions sets options for the input matching the given field name.
func (*Form) SetValues ¶ added in v0.0.2
SetValues sets values for the input matching the given field name.
func (*Form) SubmitLabel ¶ added in v0.2.3
SubmitLabel customizes the text on the submit button. If never called, the button shows Translate("Submit") (locale-aware).
func (*Form) SubmitLoadingLabel ¶ added in v0.2.4
SubmitLoadingLabel customizes the text on the submit button while submitting.
func (*Form) SyncValues ¶ added in v0.0.2
SyncValues copies all input values back into the bound struct via the Fielder's Pointers() method.