A simple library to generate HTML forms.
You need a Go version > 1.19, due to usage of generics.
go get github.com/8lall0/form
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.
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.
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
Feel free to fork and send pull requests :)
This project is licensed under the MIT License - see the LICENSE.md file for details