heartcombo/simple_form · warning

%{name} method now accepts a `wrapper_options` argument. The

Error message

%{name} method now accepts a `wrapper_options` argument. The method definition without the argument is deprecated and will be removed in the next Simple Form version. Change your code from:

    def %{name}

to

    def %{name}(wrapper_options)

See https://github.com/heartcombo/simple_form/pull/997 for more information.

What it means

The wrapper's :label_input component calls the input's #label and #input methods; since PR #997 these receive wrapper_options (the wrapper's per-component options, e.g. wrap_with classes). LabelInput#deprecated_component checks method arity: a zero-parameter definition is called without the argument and warned via SimpleForm.deprecator with CUSTOM_INPUT_DEPRECATION_WARN (lib/simple_form/components/label_input.rb:25). It fires when a custom input overrides label or input without the wrapper_options parameter.

Source

Thrown at lib/simple_form/components/label_input.rb:25

      included do
        include SimpleForm::Components::Labels
      end

      def label_input(wrapper_options = nil)
        if options[:label] == false
          deprecated_component(:input, wrapper_options)
        else
          deprecated_component(:label, wrapper_options) + deprecated_component(:input, wrapper_options)
        end
      end

      private

      def deprecated_component(namespace, wrapper_options)
        method = method(namespace)

        if method.arity.zero?
          SimpleForm.deprecator.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: namespace })

          method.call
        else
          method.call(wrapper_options)
        end
      end
    end
  end
end

View on GitHub (pinned to 18f38aad0b)

Solutions

  1. Add the parameter to overridden methods: def input(wrapper_options) — or def input(wrapper_options = nil), since an optional parameter makes arity non-zero and also silences the warning
  2. Apply the same change to any overridden label, hint, error or other component method used in wrappers
  3. In the test environment, set SimpleForm.deprecator behavior to raise so all zero-arity overrides fail in one test run instead of trickling into production logs

Example fix

# before
class UpperCaseInput < SimpleForm::Inputs::StringInput
  def input   # deprecation: missing wrapper_options
    super.upcase
  end
end

# after
class UpperCaseInput < SimpleForm::Inputs::StringInput
  def input(wrapper_options = nil)
    super(wrapper_options).upcase
  end
end
Defensive patterns

Strategy: validation

Validate before calling

# boot-time arity audit for overridden input methods
[UpperCaseInput, FancyLabelInput].each do |klass|
  %i[label input label_input].each do |name|
    next unless klass.method_defined?(name)
    Rails.logger.warn("#{klass}##{name} should accept wrapper_options") if klass.instance_method(name).arity.zero?
  end
end

Prevention

When it happens

Trigger: A custom input class defining def input or def label with no parameters, rendered through a wrapper that uses :label_input; custom inputs written for simple_form versions before PR #997 (pre-3.1) running on a newer gem.

Common situations: Upgrading simple_form with legacy custom inputs in app code or vendored gems; overriding def input for styling and forgetting the parameter; old fork/plugin inputs that never adopted the new signature.

Related errors


AI-assisted analysis of heartcombo/simple_form@18f38aad0b (2026-08-21). Data as JSON: /api/errors/1acb655fe7af05c9. Report an issue: GitHub.