views:

47

answers:

0

Hi all,

I'm developing an app which runs complex, configurable searches over multiple database tables, and displays the results. I have identified a number of different types of search I'd like to run, and have hard-coded the SQL queries to get the correct results. Each part of the queries have been abstracted, so building a query is as simple as passing a Query object to various functions, depending on how you want the query to be designed.

What I now need to do is construct a public UI, with a way of configuring a search query manually. The interface I have in mind is something akin to iTunes' Smart Playlist dialog:

alt text

The user would at first be presented with a simple drop-down menu to select a search category. On selecting a category, they'd be able to further configure the search term, based on the category type. After configuring a search term, they could either run the search, or make it more complex by adding a further search term (with a binding condition to the first term, such as AND or OR). For each different category of term, the other configurable options will be different (any there will be different numbers of options per category).

The interface isn't troubling me so much, it's the implementation. I'm using Zend Framework for the rest of the app, so I'd like to use Zend_Form where possible. Also, whilst I do plan to use AJAX to update the form (for example, asynchronously adding fields for the necessary configurable options whenever the search category is changed), I'd also like it to work without JavaScript in the first instance (for reasons of both accessibility and simplicity). Instead of AJAX firing when a category is selected/changed, I propose to just have an 'update' button for now: clicking the button would reload the page with the new fields added to the form.

I can't get my head round the best way to construct the form, to extend, validate and process it. When a new search term is configured, selecting a search category (and clicking 'update') should return a new copy of the same form, with extra fields for the configurable options. When correctly completed, there will also be a button marked 'add new search term'. Clicking that would add a whole new form (or a sub-form?) and the process repeats. I also, of course, need to keep a record of all the subforms, and the binding conditions which link each one.

As the form will be fluid, with fields being added all the time, how should I keep track of the current state of the form? Is using sessions the right way to go?

I'll also need to consider how to validate the form, and how to edit/remove previously configured search terms.

Does anyone have any advice which might be useful tome in this endeavour? Would you suggest that this approach is the sort of thing I should be researching?

Many thanks!