aboutsummaryrefslogtreecommitdiff
path: root/app/helpers/resources_helper.rb
blob: a949311941ef5687bd70786ffcb45aaae14859de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

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