Fog Creek Software
Discussion Board




XML forms definition

Hi all,

I need to setup a small little php based site to store a bunch of web forms. There are a couple of forms to start with, but the expectation is that there will be more in the days ahead. So my current idea was define the form layout and constraints (such as required/optional fields) in xml and store that as character data in the database. So for each form type I would have xml data for the layout (including visual aspects) and the constraints (based on which I can generate Javascript validation code for). And for each filled form I would store the fields filled as xml data as well and use that to populate the form of that given type for display.

Does this approach seem reasonable to you ? It seems like it would be a common way of doing things, and thats why I'd like to know if you are aware of a standard/open XML schema in use to deal with this sort of situtation. Defining my own format is fine, but I'd much rather try to re-use something if its already out there, possibly with its own form designer as well to simplify adding new forms later.

Thanks

gaz
Tuesday, September 23, 2003

Yeah building forms from a definition is a great way to generate web applications.

Since you are using a database though you might be able to go one better and use PHP to read the table structure and generate a web form straight from the table. You could determine required or optional from the record's NOT NULL status, and do some verification based on the record's datatype.

Matthew Lock
Tuesday, September 23, 2003

http://www.binarycloud.com/
They are building a open source web application platform,
using PHP and XML to generate forms etc.
Validation, filtering and such things are already included.

A warning though, it is still in development, and as most Open Source projects the releasedates are uncertain. Check it out, it is rather easy to get up and running. Have only played with it under Linux, but Windows should work as well.

Fredrik Svensson
Tuesday, September 23, 2003

Yup, I could generate the form from the table structure (and allow users to create new tables for new forms) however making it nice and pretty algorithmically will be a pain. I'm sure you can get around the problem to a certain extent by defining layout/ordering rules and possibly add some more meta-data for the table to make it more pretty, but I really don't see them wanting to, or being able to do that.

So its really from a dev perspective that I'm thinking to make it easier to add new types of forms. Since these forms really don't need to be searchable, storing the form defintion (layout and constraints) as xml text into a form-type table seems reasonable. And I'm ok with storing the form data as xml into the db as well.

I'm taking a look at the XForms standard, and possibly some proprietary template system such as http://www.sydock.com/asp/products/Info/overview.asp

Anything horribly wrong about storing xml data such as this into a db ?

gaz
Tuesday, September 23, 2003

www.altova.com

authentic plugin

Phil
Tuesday, September 23, 2003

you might want to take a look at XForms:
http://www.w3.org/MarkUp/Forms/

XForms 1.0 spec:
http://www.w3.org/TR/2003/PR-xforms-20030801/

Steve H
Tuesday, September 23, 2003

I really really don't like the idea of letting the database structure directly define your form layout.  I mean, at that point why not just give them an Excel spreadsheet with row and column layout?  The whole point of a form is that you're adding some kind of UI and validation and visual structure to the data above and beyond just what the db gives you, right?

Before you know it,  users will be asking you "Can you make just this one word bold" or "Can you move this field five pixels up and 25 pixels to the right?"  Then what are you going to do?

Jim Rankin
Wednesday, September 24, 2003

> Before you know it,  users will be asking you "Can you make
> just this one word bold" or "Can you move this field five
> pixels up and 25 pixels to the right?"  Then what are you
> going to do?

In that case you would use templates to layout a particular form with specific formatting requirements.

Matthew Lock
Thursday, September 25, 2003

*  Recent Topics

*  Fog Creek Home