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

Wrappers::Leaf is the node created by b.use :namespace inside a wrapper; at render time it looks up the method named by the namespace on the input and mirrors LabelInput: if the method's arity is zero it is called without arguments and SimpleForm.deprecator warns with CUSTOM_INPUT_DEPRECATION_WARN, otherwise it receives the leaf's @options as wrapper_options (lib/simple_form/wrappers/leaf.rb:16). It fires for any custom component method (prefix, suffix, hint, error, ...) defined without the wrapper_options parameter.

Source

Thrown at lib/simple_form/wrappers/leaf.rb:16

# frozen_string_literal: true
module SimpleForm
  module Wrappers
    class Leaf
      attr_reader :namespace

      def initialize(namespace, options = {})
        @namespace = namespace
        @options = options
      end

      def render(input)
        method = input.method(@namespace)

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

          method.call
        else
          method.call(@options)
        end
      end

      def find(name)
        self if @namespace == name
      end
    end
  end
end

View on GitHub (pinned to 18f38aad0b)

Solutions

  1. Add the parameter: def prefix(wrapper_options) (or def prefix(wrapper_options = nil)) in the component module
  2. If the component needs wrapper options (e.g. wrap_with classes), consume wrapper_options inside the method body
  3. Run the suite with deprecations raised (SimpleForm.deprecator) to find every zero-arity component method in one pass

Example fix

# before
module Prefix
  def prefix   # arity 0 -> deprecation warning from Leaf#render
    template.content_tag(:span, options[:prefix], class: 'input-group-text')
  end
end
SimpleForm.include_component Prefix

# after
module Prefix
  def prefix(wrapper_options)
    template.content_tag(:span, options[:prefix], class: 'input-group-text')
  end
end
SimpleForm.include_component Prefix
Defensive patterns

Strategy: validation

Validate before calling

# audit every included component for zero-arity methods
[Prefix, Suffix].each do |mod|
  mod.instance_methods(false).each do |name|
    if mod.instance_method(name).arity.zero?
      Rails.logger.warn("#{mod}##{name} should accept wrapper_options")
    end
  end
end

Prevention

When it happens

Trigger: b.use :prefix in wrapper config plus a custom component module defining def prefix (zero parameters) included via SimpleForm.include_component; any component method with arity 0 rendered by a Leaf node.

Common situations: Custom prepend/append components from before PR #997 used with newer simple_form; component gems that never updated their method signatures; authors needing wrap_with options in the component but defining the method without the parameter.

Related errors


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