Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I sometimes get the offer to create these and it's always a maintenance hell.

For example: a print shop wants a form so you can order your print work online. This mostly is a multiple step form where you can pick size, paper, etc and depending on the options you pick you get other options.

I can mostly hard code what they want but if they want to change something later it's very cumbersome because you have to change the form, validation and back-end to accommodate the changes.

I heard from some clients that they got offers from companies in the past that have specialized systems for this. At first I thought this was a little over kill but since you need a system that can is very flexible I am maybe wrong?

So if anybody can give examples, books, websites, videos or any other media on the matter I appreciate it.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Generating forms dynamically is pretty easy. The harder part is designing a back-end that accommodates dynamic form data. But that too shouldn't be too difficult.

The most common approach is to use an EAV model (Entity-Attribute-Value), also known as an open schema model. This is a generalized form of row modeling, which is recording facts about something across multiple rows instead of multiple columns.

So instead of having a table called Orders with fields like size, paper, color, etc. and having to modify the table schema or create a new table in order to create a new custom form, you would simply have 3 tables (Entity, Attribute, Value) in which all form data can be stored, no matter what the form looks like. In this case, each order would be a new entity, each form field would be an attribute, and of course the selected options would be the values.

This might look a little confusing at first, but once you start to implement the system everything will start to fall in place. Usually this is done in the database abstraction layer or ORM. See Magento for an example of this in action, which uses EAV to allow custom product attributes to be defined by the user.

It should be noted that many (e.g. Bill Karwin—former project manager for Zend Framework) consider EAV to be an antipattern, but I can think of no better alternatives to EAV for these cases, so the benefits outweigh the costs IMO.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.