Contents

Chapter 1

Features

This chapter covers the core features and capabilities of Form Builder.

Features

  • Programmatic HTML form generation from Python dataclasses or JSON
  • Built-in CSRF token generation (cryptographically secure)
  • Honeypot anti-spam field out of the box
  • Full ARIA accessibility: labels, describedby, required markers
  • Client-side HTML5 validation attributes (required, minlength, pattern, etc.)
  • All standard input types: text, email, select, radio, checkbox, textarea, file, date, etc.
  • JSON-driven form definitions — load forms from config files
  • Zero dependencies — Python 3.10+ stdlib only

Quick Start

bash
# Render the built-in demo contact form
python src/form_builder.py --demo

# Render from a JSON definition
python src/form_builder.py --input examples/contact_form.json

# Write output to a file
python src/form_builder.py --input examples/contact_form.json --output form.html
Chapter 2

JSON Form Definition Schema

Follow this guide to get Form Builder up and running in your environment.

JSON Form Definition Schema

json
{
  "action": "/api/contact",
  "method": "POST",
  "id": "contact-form",
  "class": "form",
  "csrf": true,
  "honeypot": true,
  "submitLabel": "Send Message",
  "fields": [
    {
      "name": "email",
      "type": "email",
      "label": "Email Address",
      "placeholder": "you@example.com",
      "required": true,
      "autocomplete": "email"
    }
  ]
}

Field Properties

PropertyTypeDescription
namestringField name attribute (required)
typestringInput type: text, email, select, textarea, etc.
labelstringHuman-readable label (auto-generated if empty)
placeholderstringPlaceholder text
requiredbooleanWhether the field is required
minLengthintegerMinimum character length
maxLengthintegerMaximum character length
minnumberMinimum numeric value
maxnumberMaximum numeric value
patternstringRegex validation pattern
optionsarrayOptions for select/radio fields
defaultstringDefault value
helpstringHelp text shown below the field
classstringAdditional CSS class for the wrapper
ariaLabelstringExplicit ARIA label override
autocompletestringAutocomplete attribute value

Python API Usage

python
from form_builder import FormConfig, FormField, FieldType, FieldOption, render_form

config = FormConfig(
    action="/api/signup",
    submit_label="Create Account",
    fields=[
        FormField(name="username", required=True, min_length=3, max_length=30),
        FormField(name="email", field_type=FieldType.EMAIL, required=True),
        FormField(name="password", field_type=FieldType.PASSWORD, required=True,
                  min_length=8, help_text="At least 8 characters"),
        FormField(name="role", field_type=FieldType.SELECT, options=[
            FieldOption("dev", "Developer"),
            FieldOption("designer", "Designer"),
            FieldOption("pm", "Product Manager"),
        ]),
    ],
)

html = render_form(config)
print(html)
Chapter 3
🔒 Available in full product

Configuration Reference

Chapter 4
🔒 Available in full product

License

You’ve reached the end of the free preview

Get the full Form Builder and unlock everything.

All Chapters

Get the complete guide with every chapter unlocked, including code samples, diagrams, and best practices.

Full Tool Suite

Access all interactive tools with complete data, all workload profiles, and the full scenario library.

Source Files

Downloadable source code, configuration files, and working examples from every chapter.

Lifetime Updates

Free updates for life. Every new chapter, tool, and improvement included.

Buy Now — $29 →
📦 Free sample included — download another copy for the full product.
Form Builder v1.0.0 — Free Preview