I have an app that uses lots of forms. I am of simple brain, and so just follow Rails' conventions. Smarter and more clever people would shun my simpleton ways.
I started with a recipe in the newest AdvancedRailsRecipes book from PragProg (very good, IMHO) that overrides form_for and helpers so that form helpers:
* accepts a label parameter that generates a label
* accepts a field help message
* accepts a "required" parameter for styling the field and for validation
* works with plugins, notably calendar_date_select
* works with child model forms (e.g. a project has many tasks)
* handles standard rails validations, even in child forms (which normal Rails doesn't, I think)
* works with other standard form_for helper parameters specific to the type
* generates consistent HTML that I style with a reasonable (if somewhat dense and old-school/non-ajaxy) CSS class
such that I can write form (new and edit) forms like
<ol>
<%= f.select :kind, Project::PROJECT_KIND, :required => true, :prompt => "Which kind is it?", :size => 30, :help => "What kind of project is this? Big, little, or just a thing to be done?" %>
<%= f.select :visibility, Project::PROJECT_VISIBILITY, :required => true, :prompt => "Who can see it?", :help => "Who can see this?" %>
<%= f.text_field :name, :required => true, :help => "A brief, descriptive title for the project to help people understand what and why more clearly." %>
<%= f.text_area :objective, :required => true, :cols => 22, :rows => 4, :help => "How will you know when this project is done?" %>
<%= f.text_area :instructions, :cols => 22, :rows => 4, :label => "Details", :help => "Other information necessary to understand the task" %>
<%= f.calendar_date_select :due_date, :class => "date", :help => "If you have a goal date for completion of the project, you can set it here. Once the project is up and running this is an important thing to keep track of!" %>
<%= f.select :status, Project::PROJECT_STATUS, :prompt => "Select a status", :help => "What's the current status of the task?" %>
</ol>
What I still feel is needed:
* have radio buttons work (bug fixed in Rails 2.1 does not generate unique ids), may also affect checkboxes
* have the scaffold generators produce the format out of the box (maybe..., or make a new generator/converter)
* have the partial that results in the add/edit forms also produce the "show" view
* come up with better html and CSS that produces nicer looking help (I am a Luddite with HTML/CSS/JS)
Feel free to look at
http://doAGreenThing.com/ which is a work in progress...
Please let me know if you're interested in the code.
Tom Harrison