Sha256: f16134b6c38e9cabab3c38318d224b4bc198720b0c100aac14f2881f63ccf2ce
Contents?: true
Size: 1.29 KB
Versions: 22
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true module Decidim module Admin # This class contains helpers needed in order for component settings to # properly render. module SettingsHelper TYPES = { boolean: :check_box, integer: :number_field, string: :text_field, text: :text_area }.freeze # Public: Renders a form field that matches a settings attribute's # type. # # form - The form in which to render the field. # attribute - The Settings::Attribute instance with the # description of the attribute. # name - The name of the field. # options - Extra options to be passed to the field helper. # # Returns a rendered form field. def settings_attribute_input(form, attribute, name, options = {}) if attribute.translated? form.send(:translated, form_method_for_attribute(attribute), name, options.merge(tabs_id: "#{options[:tabs_prefix]}-#{name}-tabs")) else form.send(form_method_for_attribute(attribute), name, options) end end private def form_method_for_attribute(attribute) return :editor if attribute.type.to_sym == :text && attribute.editor? TYPES[attribute.type.to_sym] end end end end
Version data entries
22 entries across 22 versions & 1 rubygems