form

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field interface {
	Render() string
}

Field interface for different types of form elements

type Fieldset

type Fieldset struct {
	Legend   string
	TabIndex int
	Fields   []Field
	Class    string
}

Fieldset represents a group of fields

type Form

type Form struct {
	ID           string
	Name         string
	Autocomplete bool
	Fieldsets    []*Fieldset
}

Form represents a form definition

func New

func New(id string) *Form

func (*Form) AddFieldset

func (b *Form) AddFieldset(legend string, tabIndex int, fields ...Field) *Form

func (*Form) AddInput

func (b *Form) AddInput(name, label string, typ InputType, required bool) *Form

Helper to quickly add a single input in a fieldset (common pattern)

func (*Form) AddRadioGroup

func (b *Form) AddRadioGroup(legend string, name string, options ...Option) *Form

func (*Form) Render

func (b *Form) Render() string

func (*Form) RenderCSS

func (f *Form) RenderCSS() string

func (*Form) RenderHTML

func (b *Form) RenderHTML() string

RenderHTML implements site.Component interface

func (*Form) SetAutocomplete

func (b *Form) SetAutocomplete(enable bool) *Form

type InputField

type InputField struct {
	ID       string
	Name     string
	Label    string
	Type     InputType
	Required bool
	Value    string
}

InputField represents a standard input field

func (*InputField) Render

func (f *InputField) Render() string

type InputType

type InputType string

InputType defines supported input types

const (
	Text     InputType = "text"
	Password InputType = "password"
	Email    InputType = "email"
	Number   InputType = "number"
	Date     InputType = "date"
	Hidden   InputType = "hidden"
)

type Option

type Option struct {
	Value string
	Label string
}

func Radio

func Radio(value, label string) Option

Helpers for options

type RadioGroupField

type RadioGroupField struct {
	Name    string
	Options []Option
}

RadioGroupField represents a group of radio buttons

func (*RadioGroupField) Render

func (f *RadioGroupField) Render() string

Jump to

Keyboard shortcuts

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