form

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

templ: version: v0.3.1001

templ: version: v0.3.1001

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CSRFField

func CSRFField(c echo.Context) templ.Component

CSRFField renders a hidden CSRF token input.

func DangerSection

func DangerSection(help string) templ.Component

DangerSection is the same card in the danger palette. Always rendered last on a page.

func Field

func Field(label, help string) templ.Component

Field wraps one labelled control. Every settings input gets a real label, placeholder-only inputs are not acceptable here.

func FieldError

func FieldError(field string, err string) templ.Component

FieldError renders a validation error for a form field. Always renders the element so it can be targeted by OOB swaps.

func FieldErrorOOB

func FieldErrorOOB(field string, err string) templ.Component

FieldErrorOOB renders an out-of-band swap for a field error (used with HTMX blur validation).

func GetError

func GetError(errors map[string]string, field string) string

GetError returns the error message for a field, or empty string if none.

func Inherited

func Inherited(value, from string) templ.Component

Inherited annotates a cascade field with the value it would take if left empty, and where that value comes from. Inherited names where a value came from, not just what it is: knowing that a limit is 2 cores is no use without knowing which level to go and change.

func OOBValidator

func OOBValidator(c echo.Context, field, errMsg string) error

OOBValidator renders per-field validation errors as OOB HTML swaps. Use with validate.WithOOBRenderer(form.OOBValidator).

func Save

func Save(label string) templ.Component

Save is the uniform submit control. Pass a label only where the action genuinely differs from saving (for example "Save & plan", which also runs a config plan).

func Section

func Section(title string, scope Scope, help string) templ.Component

Section is the standard settings card: title, scope badge, optional explanation, then content.

func SettingsForm

func SettingsForm(c echo.Context, postURL string) templ.Component

SettingsForm wraps a section's controls: it carries the CSRF token and wires the dirty-state tracking behind the save button. Taking the context is what makes the token automatic, a settings form that forgets it just 403s.

func SettingsFormUpload

func SettingsFormUpload(c echo.Context, postURL string) templ.Component

SettingsFormUpload is SettingsForm for a section containing a file input. htmx posts urlencoded by default, which silently drops the file, hx-encoding is what makes the upload actually arrive.

func SettingsLayout

func SettingsLayout(items []NavItem) templ.Component

SettingsLayout pairs the sub-nav with the section body.

func SettingsNav

func SettingsNav(items []NavItem) templ.Component

SettingsNav renders the left rail of a settings page. Collapses to a horizontal scroller on narrow screens.

Types

type NavItem struct {
	Label string
	Href  string
	// Active marks the section currently being viewed.
	Active bool
}

NavItem is one entry in a settings sub-nav. Href is a real URL so every section is deep-linkable and survives a reload.

type Scope

type Scope string

Scope names the level a section writes to, so a reader never has to guess how far a change reaches.

const (
	ScopeInstance Scope = "instance"
	ScopeUser     Scope = "you"
	ScopeOrg      Scope = "organization"
	ScopeStack    Scope = "stack"
	ScopeEnv      Scope = "environment"
	ScopeTile     Scope = "service"
)

Jump to

Keyboard shortcuts

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