Skip to content

Commit 94f16fb

Browse files
committed
Add ability to show a help text under the search box
1 parent b9ee7f0 commit 94f16fb

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

app/views/rails_admin/main/index.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@
8383
<i class="fas fa-times"></i>
8484
</button>
8585
</div>
86+
<% if @model_config.list.search_help.present? %>
87+
<div class="form-text"><%= @model_config.list.search_help %></div>
88+
<% end %>
8689
</div>
8790
<div class="col-sm-6 text-end">
8891
<% if export_action %>

lib/rails_admin/config/sections/list.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ class List < RailsAdmin::Config::Sections::Base
3030
nil
3131
end
3232

33+
register_instance_option :search_help do
34+
nil
35+
end
36+
3337
register_instance_option :sort_by do
3438
parent.abstract_model.primary_key
3539
end

spec/integration/actions/index_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,16 @@
321321
},
322322
]
323323
end
324+
325+
it 'shows the help text below the search box' do
326+
RailsAdmin.config Player do
327+
list do
328+
search_help 'Use this box to search!'
329+
end
330+
end
331+
visit index_path(model_name: 'player')
332+
is_expected.to have_css('.form-text', text: /Use this box/)
333+
end
324334
end
325335

326336
describe 'fields' do

0 commit comments

Comments
 (0)