Permalink
Browse files

respect config include_in_advanced_search=false again, as documented

  • Loading branch information...
jrochkind committed Apr 12, 2012
1 parent e43608a commit 7b00f5844d9fa01da1445e9fefb5e7d6bf3c14f0
Showing with 15 additions and 3 deletions.
  1. +14 −2 app/helpers/advanced_helper.rb
  2. +1 −1 app/views/advanced/_advanced_search_fields.html.erb
@@ -33,8 +33,20 @@ def advanced_search_context
my_params
end
- def search_fields_for_advanced_search
- blacklight_config.search_fields
+ def search_fields_for_advanced_search
+ # If we could count on 1.9.3 with ordered hashes and
+ # Hash#select that worked reasonably, this would be trivial.
+ # instead, a way compat with 1.8.7 and 1.9.x both.
+ @search_fields_for_advanced_search ||= begin
+ # make it an ActiveSupport::OrderedHash if it needs to be
+ hash = blacklight_config.search_fields.class.new
+
+ blacklight_config.search_fields.each_pair do |key, value|
+ hash[key] = value unless value.include_in_advanced_search == false
+ end
+
+ hash
+ end
end
end
@@ -1,4 +1,4 @@
-<%- blacklight_config.search_fields.each do |key, field_def| -%>
+<%- search_fields_for_advanced_search.each do |key, field_def| -%>
<div class="advanced_search_field">
<%= label_tag key, "#{field_def.label }:" %>
<%= text_field_tag key, label_tag_default_for(key) %>

0 comments on commit 7b00f58

Please sign in to comment.