Skip to main content
https://ci.appveyor.com/api/projects/status/rj4y4vppa4m7l2ar?svg=true https://circleci.com/gh/blazelibs/blazeform.svg?style=shield https://codecov.io/gh/blazelibs/blazeform/branch/master/graph/badge.svg

Introduction

BlazeForm is a library designed to facilitate the rendering/processing/validating of HTML forms.

Features

  • validation based on FormEncode

  • attempting to have complete HTML spec coverage

  • extensible rendering system() (don’t have to use it)

  • will work with multiple WSGI frameworks (Werkzeug currently supported)

  • extensive unit tests

  • few dependencies: FormEncode, BlazeUtils, WebHelpers2

Code Sample

Using it might look like this:

class MyForm(Form):
    def __init__(self):
        Form.__init__(self, 'myform')

        el = self.els.add_header('input-els', 'Optional Elements')
        el = self.els.add_button('button', 'Button', defaultval='PushMe')
        el = self.els.add_checkbox('checkbox', 'Checkbox')
        el = self.els.add_file('file', 'File')
        el = self.els.add_hidden('hidden', defaultval='my hidden val')
        el = self.els.add_image('image', 'Image', defaultval='my image val', src='images/icons/b_edit.png')
        el = self.els.add_text('text', 'Text')
        el.add_note('a note')
        el.add_note('an <strong>HTML</strong> note', False)
        el = self.els.add_text('nolabel', defaultval='No Label')
        el.add_note('a note')
        el = self.els.add_password('password', 'Password')
        el = self.els.add_confirm('confirm', 'Confirm Password', match='password')
        el.add_note('confirm characters for password field are automatically masked')
        el = self.els.add_date('date', 'Date', defaultval=datetime.date(2009, 12, 3))
        el.add_note('note the automatic conversion from datetime object')
        emel = self.els.add_email('email', 'Email')
        el = self.els.add_confirm('confirmeml', 'Confirm Email', match=emel)
        el.add_note('note you can confirm with the name of the field or the element object')
        el.add_note('when not confirming password field, characters are not masked')
        el = self.els.add_time('time', 'Time')
        el = self.els.add_url('url', 'URL')
        options = [('1', 'one'), ('2','two')]
        el = self.els.add_select('select', options, 'Select')
        el = self.els.add_mselect('mselect', options, 'Multi Select')
        el = self.els.add_textarea('textarea', 'Text Area')
        el = self.els.add_fixed('fixed', 'Fixed', 'fixed val')
        el = self.els.add_fixed('fixed-no-label', defaultval = 'fixed no label')
        el = self.els.add_static('static', 'Static', 'static val')
        el = self.els.add_static('static-no-label', defaultval='static val no label')

and the view/controller code might look something like:

class FormTest(HtmlTemplatePage):
    def prep(self):
        self.form = MyForm()

    def post(self):
        if self.form.is_cancel():
            self.assign('cancel', True)
        elif self.form.is_valid():
            self.assign('values', self.form.get_values())
        elif self.form.is_submitted():
            # form was submitted, but invalid
            self.form.assign_user_errors()
        self.default()

    def default(self):
        self.assign('form', self.form)

Questions & Comments

Please visit: http://groups.google.com/group/blazelibs

Current Status

The code stays pretty stable, but the API may change, especially the rending.

The blazeform tip is installable via easy_install with easy_install blazeform==dev

Changelog

0.5.1 released 2020-10-23

  • Fix mutable default argument in tolist (556fcf0)

0.5.0 released 2020-07-14

  • drop support for python 2

  • modernize package setup and CI

  • support python 3.8 (1d9afa9)

0.4.2 released 2018-01-17

  • handle string type in file upload for blank submissions

0.4.1 released 2017-06-02

  • update validation messages for consistency across python versions

0.4.0 released 2016-11-23

  • added support for Python 3 (3.4 and 3.5)

  • set up CI and coverage

0.3.9 released 2016-05-20

  • make is_empty more general with respect to input type, 0 should not be empty

0.3.8 released 2016-02-24

  • update compatibility with FormEncode to include 1.3

0.3.7 released 2014-10-27

  • fix checkbox element to handle empty value as on/true for IE 9/10 compat.

0.3.6 released 2014-10-15

  • allow labels for logical groups, such as radio buttons or checkboxes

0.3.5 released 2014-08-20

  • ensure that form validators and element processors which are FE validators are instances

0.3.4 released 2012-07-05

  • form now has all_errors() method which returns form and field errors as (list, dict) tuple (respectively).

  • update the way file uploads are checked for being sent. Previously, we were testing for the filename header to be None, but Werkzeug is sending it over as an empty string in the FileStorage object now. Could theoretically result in behavior change, but only in narrow edge cases.

0.3.3 released 2011-11-16

  • TextAreaElement now uses maxlength kwarg

0.3.2 released 2011-06-11

  • fix broken distribution of 0.3.1

0.3.1 released 2011-06-11

  • fixed bug in radio button rendering after validation error

Metadata

Release files for BlazeForm 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for BlazeForm 0.5.1
File Size Uploaded
BlazeForm-0.5.1.tar.gz 48.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for BlazeForm 0.5.1
File Interpreter ABI Platform
BlazeForm-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 101.6 kB

Release files / BlazeForm-0.5.1.tar.gz

Download URL BlazeForm-0.5.1.tar.gz
Size 48.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e77ea90a1f381f6e67e9846c18fe6b2bc90cd9f2deef39e82bd7b328b7ea828b
BLAKE2b-256 checksum
How to use checksums
827fad825a725db4ca36ad901d22a7aaba08b688e68ab6f1780f4a36f4fac158
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release files / BlazeForm-0.5.1-py3-none-any.whl

Download URL BlazeForm-0.5.1-py3-none-any.whl
Size 53.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7fede7fb7ac0a5f88c9032eac0c9b191b5c88d24c083e07b3129f1bc2bc3eea1
BLAKE2b-256 checksum
How to use checksums
170240684d398ff33f8e3e4c6cca191f8e7563a736b3cc385b160e5208c563be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.2

3 release files

0.4.1

1 release file

0.4.0

1 release file

0.3.9

1 release file

0.3.8

1 release file

0.3.7

1 release file

0.3.6

1 release file

0.3.5

1 release file

0.3.4

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

2 release files

0.3.0dev

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page