Skip to content

Commit faeeeab

Browse files
committed
[Fixes browsermedia#726] Allow search to work for Form Entries
Searches all data columns.
1 parent 88c03d2 commit faeeeab

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

app/controllers/cms/form_entries_controller.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,16 @@ def bulk_update
5252
# Same behavior as ContentBlockController#index
5353
def index
5454
@form = Cms::Form.where(id: params[:id]).first
55-
@blocks = Cms::FormEntry.where(form_id: params[:id]).paginate({page: params[:page], order: params[:order]})
56-
@entry = Cms::FormEntry.for(@form)
57-
55+
5856
# Allows us to use the content_block/index view
5957
@content_type = FauxContentType.new(@form)
6058
@search_filter = SearchFilter.build(params[:search_filter], Cms::FormEntry)
59+
60+
@blocks = Cms::FormEntry.where(form_id: params[:id]).search(@search_filter.term).paginate({page: params[:page], order: params[:order]})
61+
@entry = Cms::FormEntry.for(@form)
62+
6163
@total_number_of_items = @blocks.size
64+
6265
end
6366

6467
def edit

app/models/cms/form_entry.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ def enable_validations
2323

2424
class << self
2525

26+
def search(term)
27+
where("data_columns like ?", "%#{term}%")
28+
end
29+
2630
# Create an Entry for a specific Form. It will have validation and accessors based on the fields of the form.
2731
#
2832
# @param [Cms::Form] form

app/views/cms/content_block/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="padded row-fluid clearfix">
33
<h1 class="span3">Assets</h1>
44

5-
<%= form_for @search_filter, url: engine_aware_path(@search_filter.model_class), html: {class: 'form-search'}, method: :get do |f| %>
5+
<%= form_for @search_filter, url: url_for({}), html: {class: 'form-search'}, method: :get do |f| %>
66
<%= f.text_field :term, class: "span6 search-query right", placeholder: "Search #{content_type.display_name_plural}" %>
77
<% end %>
88
</div>

0 commit comments

Comments
 (0)