Clean dynamically generated forms... is there a way?

I’m trying to write a UI for a reports view that has (lets say) the
following reports:

  1. Company overview
  2. Person detail
  3. Projects overview

The idea is that you choose which one of those reports you want using
a SELECT box. When you’ve chosen the report you want the options (if
there are any) for that report are displayed. So let’s say we have the
following options:

  1. Company overview
    This just displays the report which lets say is a partial that we put
    in a span. Easy.

  2. Person detail
    For this we want a new SELECT to appear with all the possible projects
    in (lets say), then when that is selected we display the result in a
    span.

  3. Projects overview
    Here we want a SELECT box and a checkbox they do … something (what
    they do is irrelevant). On changing them though we update the div with
    the displayed report using those options.

I already have a solution for this that is really big and unwieldy and
… wrong… It uses AJAX because I came across it and thought it was
shiny. This has the problem though that if you use a link on the
report and then go back you only get the first select box appearing.
Basically back button doesn’t quite work badness. So an AJAXy solution
would be nice, but I really want the back button to work.

The second issue is that my current solution has reams and reams of
code. About 30 lines per potential report which is clearly not
ruby-like.

So I’m wondering if anyone can tell me where to RTFM or point out
anything I should look at or consider, or not consider :slight_smile: Any help
appreciated :slight_smile:

-Rob

“I am a strong advocate for free thought on all subjects, yet it
appears to me (whether rightly or wrongly) that direct arguments
against christianity & theism produce hardly any effect on the public;
& freedom of thought is best promoted by the gradual illumination of
men’s minds, which follow[s] from the advance of science. It has,
therefore, been always my object to avoid writing on religion, & I
have confined myself to science.” - Darwin

http://www.robhulme.com/

It would seem to me that the three reports you require could be
rendered as separate actions (each belonging to it’s model/controller.
with it’s own view’ ie. build each report page first. And then the
main select box ‘menu’ would be a call to an action in the controller
that would do a redirect_to the appropriate page.

Perhaps there is a reason you do not choose to do it this way

Tony