|
1 | 1 | <% association = model.reflections[field.to_s] %> |
2 | 2 | <% if association %> |
3 | | - <% field_key = model.ransackable_scopes.include?(field) ? field : "#{field}_id_in" %> |
4 | | - <% desc = association.klass.method_defined?(:admin_label) ? :admin_label : :to_s %> |
5 | | - <% collection = association.klass.send(association.klass.respond_to?(:admin_scope) ? :admin_scope : :all) %> |
| 3 | + <% field_key = AdministrateRansack.ransack?(model, {field => "1,2"}) ? field : "#{field}_id_in" %> |
| 4 | + <% resource_field = type.new(field, nil, Administrate::Page::Collection.new(@dashboard), resource: model.new) %> |
| 5 | + <% collection = resource_field.associated_resource_options %> |
6 | 6 |
|
7 | | - <%= form.label(label, class: 'filter-label') %> |
| 7 | + <%= form.label(label || field_key, class: 'filter-label') %> |
8 | 8 | <% if options&.include? 'select' %> |
9 | | - <%= form.select(field_key, nil, {}, multiple: true) do %> |
10 | | - <%= options_from_collection_for_select(collection, :id, desc) %> |
11 | | - <% end %> |
| 9 | + <%= form.select(field_key, collection, {}, multiple: true) %> |
12 | 10 | <% else %> |
13 | | - <%= form.collection_check_boxes(field_key, collection, :id, desc) do |b| %> |
| 11 | + <%= form.collection_check_boxes(field_key, collection, :second, :first) do |b| %> |
14 | 12 | <%= b.label do %> |
15 | 13 | <%= b.check_box %> |
16 | | - <span><%= b.object.send(desc) %></span> |
| 14 | + <span><%= b.text %></span> |
17 | 15 | <% end %> |
18 | 16 | <% end %> |
19 | 17 | <% end %> |
|
0 commit comments