From 3ea22f64faa08b707d0d4ed6539a5b5debe1f190 Mon Sep 17 00:00:00 2001 From: hellekin Date: Fri, 9 Oct 2020 10:33:25 +0200 Subject: Add a selector for categories and sections --- app/helpers/resources_helper.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app') diff --git a/app/helpers/resources_helper.rb b/app/helpers/resources_helper.rb index bbdde9a..157a8f5 100644 --- a/app/helpers/resources_helper.rb +++ b/app/helpers/resources_helper.rb @@ -1,2 +1,12 @@ module ResourcesHelper + # Return a SELECT tag to choose a section in a given taxonomy + def section_select(taxonomy, selected = nil) + grouped_options = [] + + taxonomy.categories.each do |c| + grouped_options << [c.name, c.sections.map { |s| [s.name, s.id] }] + end + + select_tag('classification[section_ids]', grouped_options_for_select(grouped_options), selected: selected, multiple: true) + end end -- cgit v1.2.3