diff --git a/app/helpers/admin/configs_helper.rb b/app/helpers/admin/configs_helper.rb index 8124c2ca..4f671fb7 100644 --- a/app/helpers/admin/configs_helper.rb +++ b/app/helpers/admin/configs_helper.rb @@ -1,12 +1,14 @@ module Admin::ConfigsHelper # Returns form input for configuration key. # For configuration keys that contain a {Hash}, {ActiveView::Helpers::FormBuilder#fields_for fields_for} can be used. + # When the key is not {FoodsoftConfig#allowed_key? allowed}, +nil+ is returned. # @param form [ActionView::Helpers::FormBuilder] Form object. # @param key [Symbol, String] Configuration key. # @param options [Hash] Options passed to the form builder. # @option options [Boolean] :required Wether field is shown as required (default not). # @return [String] Form input for configuration key. def config_input(form, key, options = {}, &block) + return unless @cfg.allowed_key? key options[:label] = config_input_label(form, key) options[:required] ||= false options[:input_html] ||= {} @@ -36,6 +38,7 @@ module Admin::ConfigsHelper # @see config_input # @todo find out how to pass +checked_value+ and +unchecked_value+ to +input_field+ def config_input_field(form, key, options = {}) + return unless @cfg.allowed_key? :key config_input_field_options form, key, options config_input_tooltip_options form, key, options if options[:as] == :boolean diff --git a/lib/foodsoft_config.rb b/lib/foodsoft_config.rb index 71d9426c..5878470c 100644 --- a/lib/foodsoft_config.rb +++ b/lib/foodsoft_config.rb @@ -130,7 +130,7 @@ class FoodsoftConfig # @return [Boolean] Whether this key may be set in the database def allowed_key?(key) # fast check for keys without nesting - return !self.config[:protected].keys.include?(key) + return !self.config[:protected].keys.include?(key.to_s) # @todo allow to check nested keys as well end