I want an online form builder

I see a form consisting of the following elements:

objects -> fields
presentation = layout + style

I want to be able to build forms programmatically like this:

account_form = new form()
account_form.add_presentor(account_html_layout, site_style)
account_form.add_validation_rule(min_length(account.first_name, 2))
account_form.add_trigger(onblur(account.first_name, validate(account.first_name))

presentation = layout + style

A form should be a first class object that understands the “form data object” (thinking like struts 1 form beans) and can be validated and rendered.

account_form.render() // renders using the default (or only in this case) presentation unless specified

Maybe I don’t want to add a presentation to the form, I want to call

account_html_presenter = new presenter()
account_html_presenter.layout = account_html_layout
account_html_presenter.style = site_style


account_presenter.render(account_form, html_presentation)

so I can define what an account business object is, then have the form understand it (like a bean) and be able to attach presentation, validation, and triggers. It could inherit default presentation and validation rules based on typing and meta-data (such as numeric only characters for an integer field, or an input with size=15 for a varchar(15)), and of course the defaults can be customized.

Fields can be inferred from the objects, or added/removed based on need. The tricky part will be in being able to pass validation and presentation info to inferred fields like I demonstrated above.

A presenter could include a label, an input, and decorators (like an asterisk denoting required, or a help icon) and conditional decorators (like a validation error notification) or conditional formatting (like changed length after text is entered) or conditionally disabled fields (such as submit before checking “Accept”)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s