Sha256: 88086ff9b597e48e3aa85879be43a24d43021b3d4d33cf7dcefab8333bfd4a0e

Contents?: true

Size: 918 Bytes

Versions: 2

Compression:

Stored size: 918 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # This class contains helpers needed in order for feature 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 = {})
        form.send(TYPES[attribute.type.to_sym], name, options)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
decidim-admin-0.4.4 app/helpers/decidim/admin/settings_helper.rb
decidim-0.4.4 decidim-admin/app/helpers/decidim/admin/settings_helper.rb