Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've been wondering about applications that have a set of checkboxes or radio buttons, even collections of form fields in their UI.

At this moment I'm handling all the choices separately but of course this becomes a complete mess very quickly. There has to be an established way to deal with this that I don't know of.

If check box a is unchecked then check boxes d through e are enabled etc. etc.

How should I be approaching this? Not in the UI of course, that's for sure. I would love to hear some insights and best practices as well as potential pitfalls.

(BTW: I've tagged this "rules-engine" because I haven't got a clue what to tag this. Please feel free to edit the question, retag and remove this line.)

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I built an e-commerce site with a complicated set of product configurations. When the user went to the individual product's configuration page, it needed to load the available options, enable/disable controls based on the choices made, and update price on-the-fly.

The data model stored all of the possible options for every product. I wrote a ConfigurationEngine class which contained the logic for all of the allowed combinations (many simple cases were stored in the DB, others had to be coded). When the user made any change on the product configuration page I made an AJAX call. The server would put together the product object with its selected configuration and pass it through the ConfigurationEngine. The product came out validated and priced. Another function on the engine would tell us which remaining options were still available. The product price, validation messages, and remaining available options were then passed back to the front-end in response to the AJAX call.

share|improve this answer

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.