Module: Decidim::Admin::SettingsHelper
- Includes:
- ScopesHelper
- 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, scope: :scope_field, enum: :collection_radio_buttons, time: :datetime_field }.freeze
Instance Method Summary collapse
-
#settings_attribute_input(form, attribute, name, i18n_scope, options = {}) ⇒ Object
Public: Renders a form field that matches a settings attribute’s type.
Instance Method Details
#settings_attribute_input(form, attribute, name, i18n_scope, 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.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/helpers/decidim/admin/settings_helper.rb', line 30 def settings_attribute_input(form, attribute, name, i18n_scope, = {}) form_method = form_method_for_attribute(attribute) container_class = "#{name}_container" if [:readonly] container_class += " readonly_container" help_text = text_for_setting(name, "readonly", i18n_scope) end help_text ||= text_for_setting(name, "help", i18n_scope) = help_text ? { help_text: help_text } : {} = { label: t(name, scope: i18n_scope) } .merge() .merge((form_method)) .merge() content_tag(:div, class: container_class) do if attribute.translated? [:tabs_id] = "#{.delete(:tabs_prefix)}-#{name}-tabs" form.send(:translated, form_method, name, ) elsif form_method == :collection_radio_buttons render_enum_form_field(form, attribute, name, i18n_scope, ) elsif form_method == :scope_field scopes_picker_field(form, name) else form.send(form_method, name, ) end end.html_safe end |