I’m using ActiveScaffold. It has a collection of Ajax enabled .rhtml
templates and helpers which collectively peform a lot of magic. Very
powerful but not easy to follow.
Anyway, the List scaffold page includes a Search form with a single
text field… When user submits the search form the text contents are
applied to the where clause and the list is regenerated.
I found that by adding additional input fields (selects) to the Search
form template, that these additional field values were being appended
to the where clause AND nicely propagated to all of the other actions
on the scaffold (like column sort and pagination).
But there was one glitch. When I added the “:include_blank => true” to
my selects I found that the auto-appended where criteria now included
“where city_id = NULL” which obviously makes my select return 0 rows.
Here’s an example of the _search.rhtml template with my mods
My only add is
Country<%= collection_select(
:country_id,:nil , ViewCountry.find(:all), :id, :country,
{ :include_blank => true } ) %>
<% href = url_for(params_for(:action => :update_table, :escape =>
false)) -%>
<%= form_remote_tag :url => href,
:method => :get,
:before =>
“addActiveScaffoldPageToHistory(’#{href}’, ‘#{params[:controller]}’)”,
:after => “$(’#{loading_indicator_id(:action
=> :search, :id => params[:id])}’).style.visibility = ‘visible’;
Form.disable(’#{search_form_id}’);”,
:complete => “$(’#{loading_indicator_id(:action
=> :search, :id => params[:id])}’).style.visibility = ‘hidden’;
Form.enable(’#{search_form_id}’);”,
:failure =>
“ActiveScaffold.report_500_response(’#{active_scaffold_id}’)”,
:update => active_scaffold_content_id,
:html => { :href => href, :id =>
search_form_id, :class => ‘search’ } %>
Country<%= collection_select(
:country_id,:nil , ViewCountry.find(:all), :id, :country,
{ :include_blank => true } ) %>
<%= submit_tag _(‘SEARCH_BUTTON’), :class => “submit” %>
<%= _(‘RESET_BUTTON’) -%></
a>
<%= loading_indicator_tag(:action => :search) %>