{"record":{"id":"7ee8d7fc3d187d2b","repo":"heartcombo/simple_form","slug":"name-method-now-accepts-a-wrapper-options-arg-7ee8d7","errorCode":null,"errorMessage":"%{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:\n\n    def %{name}\n\nto\n\n    def %{name}(wrapper_options)\n\nSee https://github.com/heartcombo/simple_form/pull/997 for more information.","messagePattern":"%(.+?) 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:\n\n    def %(.+?)\n\nto\n\n    def %(.+?)\\(wrapper_options\\)\n\nSee https://github\\.com/heartcombo/simple_form/pull/997 for more information\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/simple_form/wrappers/leaf.rb","lineNumber":16,"sourceCode":"# frozen_string_literal: true\nmodule SimpleForm\n  module Wrappers\n    class Leaf\n      attr_reader :namespace\n\n      def initialize(namespace, options = {})\n        @namespace = namespace\n        @options = options\n      end\n\n      def render(input)\n        method = input.method(@namespace)\n\n        if method.arity.zero?\n          SimpleForm.deprecator.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: @namespace })\n\n          method.call\n        else\n          method.call(@options)\n        end\n      end\n\n      def find(name)\n        self if @namespace == name\n      end\n    end\n  end\nend\n","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/heartcombo/simple_form/blob/18f38aad0bdeca2ba1815043b94d96fdbbe6a325/lib/simple_form/wrappers/leaf.rb#L1-L30","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add the parameter: def prefix(wrapper_options) (or def prefix(wrapper_options = nil)) in the component module","If the component needs wrapper options (e.g. wrap_with classes), consume wrapper_options inside the method body","Run the suite with deprecations raised (SimpleForm.deprecator) to find every zero-arity component method in one pass"],"exampleFix":"# before\nmodule Prefix\n  def prefix   # arity 0 -> deprecation warning from Leaf#render\n    template.content_tag(:span, options[:prefix], class: 'input-group-text')\n  end\nend\nSimpleForm.include_component Prefix\n\n# after\nmodule Prefix\n  def prefix(wrapper_options)\n    template.content_tag(:span, options[:prefix], class: 'input-group-text')\n  end\nend\nSimpleForm.include_component Prefix","handlingStrategy":"validation","validationCode":"# audit every included component for zero-arity methods\n[Prefix, Suffix].each do |mod|\n  mod.instance_methods(false).each do |name|\n    if mod.instance_method(name).arity.zero?\n      Rails.logger.warn(\"#{mod}##{name} should accept wrapper_options\")\n    end\n  end\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Define component methods as def name(wrapper_options); consume wrapper_options when you need wrap_with options","Run the test suite with SimpleForm.deprecator set to raise during upgrades to flush all zero-arity components at once","For new components, copy the (wrapper_options) signature from simple_form's built-in components"],"tags":["simple-form","deprecation","wrapper-options","leaf","custom-component"],"backgroundTag":"deprecated-method-signature","analyzedSha":"18f38aad0bdeca2ba1815043b94d96fdbbe6a325","analyzedAt":"2026-08-21T18:23:08.988Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}