aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhellekin <hellekin@cepheide.org>2020-10-09 10:33:25 +0200
committerhellekin <hellekin@cepheide.org>2020-10-09 10:33:25 +0200
commit3ea22f64faa08b707d0d4ed6539a5b5debe1f190 (patch)
treea9d7154e32c6b454f88bfd6ec80a8ad70114a712
parentef9ff49462c3fdf10d0cdcbb6304715769485835 (diff)
downloadincommon-map-3ea22f64faa08b707d0d4ed6539a5b5debe1f190.tar.gz
Add a selector for categories and sections
-rw-r--r--app/helpers/resources_helper.rb10
1 files changed, 10 insertions, 0 deletions
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