Module: Decidim::Admin::SettingsHelper
- Defined in:
- app/helpers/decidim/admin/settings_helper.rb
Overview
This class contains helpers needed in order for component settings to properly render.
Constant Summary collapse
- TYPES =
{ boolean: :check_box, integer: :number_field, string: :text_field, text: :text_area }.freeze
Instance Method Summary collapse
-
#help_text_for_component_setting(field_name, settings_name, component_name) ⇒ Object
Returns a translation or nil.
-
#settings_attribute_input(form, attribute, name, options = {}) ⇒ Object
Public: Renders a form field that matches a settings attribute’s type.
Instance Method Details
#help_text_for_component_setting(field_name, settings_name, component_name) ⇒ Object
Returns a translation or nil. If nil, ZURB Foundation won’t add the help_text.
41 42 43 44 |
# File 'app/helpers/decidim/admin/settings_helper.rb', line 41 def help_text_for_component_setting(field_name, settings_name, component_name) key = "decidim.components.#{component_name}.settings.#{settings_name}.#{field_name}_help" return t(key) if I18n.exists?(key) end |
#settings_attribute_input(form, attribute, name, options = {}) ⇒ Object
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.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/decidim/admin/settings_helper.rb', line 25 def settings_attribute_input(form, attribute, name, = {}) if name == :amendments_visibility amendments_visibility_form_field(form, ) elsif attribute.translated? form_method = form_method_for_attribute(attribute) = { tabs_id: "#{[:tabs_prefix]}-#{name}-tabs" } = .merge((form_method)) form.send(:translated, form_method, name, .merge()) else form_method = form_method_for_attribute(attribute) = (name).merge((form_method)) form.send(form_method, name, .merge()) end end |