form

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: MIT Imports: 4 Imported by: 0

README

Form

A simple library to generate HTML forms.

System Requirements

You need a Go version > 1.19, due to usage of generics.

Install

go get github.com/8lall0/form

Usage

Create a new form, create some form/field fields and append them to the Fields attribute of form in order of appearance.

When in doubt, just see the examples in the examples/ directory.

Template

The examples come with some ready to use templates inside examples/template/default.

If you want to use a custom template, you can modify the default one or create one from scratch, following the same filenames. You can pass the new template path inside the TemplatePath attribute of a form.

Custom fields

You can define custom fields as you want, they only have to satisfy the form/field.Field interface, which requires this signature:

Render(string, io.Writer) error

Contributions

Feel free to fork and send pull requests :)

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Form

type Form struct {
	Action       string
	Method       string
	Id           string
	IsMultiPart  bool
	Fields       []field.Field
	TemplatePath string
}

func (*Form) Render

func (f *Form) Render(w io.Writer) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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